From: Kilian Saffran Date: Fri, 15 Apr 2022 08:28:14 +0000 (+0200) Subject: v20220415 X-Git-Url: http://cloud.dks.lu/git/?a=commitdiff_plain;h=515c3228d01c6ef8b403b59abda6dca464c3b298;p=pot_lu.git v20220415 --- diff --git a/.gitignore b/.gitignore index e503ca2b..9d8fd28b 100644 --- a/.gitignore +++ b/.gitignore @@ -16,5 +16,5 @@ release install/tmp/* app/sql.log app/put.log -app/log/*.log +app/log/ app/vendors/tabulator/5.0 diff --git a/app/log/sql.log b/app/log/sql.log index 848a0058..e69de29b 100644 --- a/app/log/sql.log +++ b/app/log/sql.log @@ -1,94760 +0,0 @@ -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='336fcfff-a3e1-4812-3202-24b12653dd1d' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '336fcfff-a3e1-4812-3202-24b12653dd1d' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '336fcfff-a3e1-4812-3202-24b12653dd1d' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='336fcfff-a3e1-4812-3202-24b12653dd1d' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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 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 ttr.*, st.* ,stg.groupname,'' || COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' 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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from davincenzo.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='davincenzo') ttr -where st.isdeleted is null order by groupname,st.staffnumber,surname,prename; -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' order by vacyear; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and date_trunc('year',spd.daydate)=date_trunc('year',date('1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3')) - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' 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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from davincenzo.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='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; -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' order by startdate,enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and date_trunc('year',spd.daydate)=date_trunc('year',date('1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3')) - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,trackername from davincenzo.timetrackerconfig order by trackername -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 ttr.*, st.* ,stg.groupname,'' || COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' 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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from davincenzo.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='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; -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' order by startdate,enddate; -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' order by vacyear; -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='336fcfff-a3e1-4812-3202-24b12653dd1d' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '336fcfff-a3e1-4812-3202-24b12653dd1d' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '336fcfff-a3e1-4812-3202-24b12653dd1d' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='336fcfff-a3e1-4812-3202-24b12653dd1d' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='336fcfff-a3e1-4812-3202-24b12653dd1d' order by vacyear; -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' order by startdate,enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' - 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 davincenzo.staffvacancyyear where id_staff='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' order by vacyear; -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='336fcfff-a3e1-4812-3202-24b12653dd1d' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '336fcfff-a3e1-4812-3202-24b12653dd1d' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='336fcfff-a3e1-4812-3202-24b12653dd1d' order by startdate,enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '336fcfff-a3e1-4812-3202-24b12653dd1d' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and date_trunc('year',spd.daydate)=date_trunc('year',date('336fcfff-a3e1-4812-3202-24b12653dd1d')) - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' - 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 davincenzo.staffvacancyyear where id_staff='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' order by vacyear; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and date_trunc('year',spd.daydate)=date_trunc('year',date('1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3')) - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='27d13a44-0d65-347a-055b-2e993f5b5561' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '27d13a44-0d65-347a-055b-2e993f5b5561' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='27d13a44-0d65-347a-055b-2e993f5b5561' order by startdate,enddate; -yhours, '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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '27d13a44-0d65-347a-055b-2e993f5b5561' - 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 davincenzo.staffvacancyyear where id_staff='27d13a44-0d65-347a-055b-2e993f5b5561' order by vacyear; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and date_trunc('year',spd.daydate)=date_trunc('year',date('27d13a44-0d65-347a-055b-2e993f5b5561')) - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='410d087c-15c7-6e72-4811-6e44f2056916' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='410d087c-15c7-6e72-4811-6e44f2056916' order by vacyear; -_staff='410d087c-15c7-6e72-4811-6e44f2056916' order by startdate,enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and date_trunc('year',spd.daydate)=date_trunc('year',date('410d087c-15c7-6e72-4811-6e44f2056916')) - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '410d087c-15c7-6e72-4811-6e44f2056916' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select * from davincenzo.staff where id='27d13a44-0d65-347a-055b-2e993f5b5561' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '27d13a44-0d65-347a-055b-2e993f5b5561' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='27d13a44-0d65-347a-055b-2e993f5b5561' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='27d13a44-0d65-347a-055b-2e993f5b5561' order by vacyear; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and date_trunc('year',spd.daydate)=date_trunc('year',date('27d13a44-0d65-347a-055b-2e993f5b5561')) - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='3fba3d93-55ff-c3ad-e2c5-0ca83c4d73c5' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='3fba3d93-55ff-c3ad-e2c5-0ca83c4d73c5' order by startdate,enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and date_trunc('year',spd.daydate)=date_trunc('year',date('3fba3d93-55ff-c3ad-e2c5-0ca83c4d73c5')) - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '3fba3d93-55ff-c3ad-e2c5-0ca83c4d73c5' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '3fba3d93-55ff-c3ad-e2c5-0ca83c4d73c5' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='998f0d4b-3e14-6198-53b1-7e117944921e' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '998f0d4b-3e14-6198-53b1-7e117944921e' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '998f0d4b-3e14-6198-53b1-7e117944921e' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='998f0d4b-3e14-6198-53b1-7e117944921e' order by startdate,enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and date_trunc('year',spd.daydate)=date_trunc('year',date('998f0d4b-3e14-6198-53b1-7e117944921e')) - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='3465d3a7-a883-624c-f677-17864861a2d5' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='3465d3a7-a883-624c-f677-17864861a2d5' order by vacyear; -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '3465d3a7-a883-624c-f677-17864861a2d5' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and date_trunc('year',spd.daydate)=date_trunc('year',date('3465d3a7-a883-624c-f677-17864861a2d5')) - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '3465d3a7-a883-624c-f677-17864861a2d5' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='3465d3a7-a883-624c-f677-17864861a2d5' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' order by vacyear; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' order by startdate,enddate; -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and date_trunc('year',spd.daydate)=date_trunc('year',date('1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3')) - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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 ttr.*, st.* ,stg.groupname,'' || COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' 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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from davincenzo.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='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,trackername from davincenzo.timetrackerconfig order by trackername -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' order by startdate,enddate; -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' - 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 davincenzo.staffvacancyyear where id_staff='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' order by vacyear; -t,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and date_trunc('year',spd.daydate)=date_trunc('year',date('1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3')) - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: 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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and date_trunc('year',spd.daydate)=date_trunc('year',date('2022-01-01')) - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: 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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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 ttr.*, st.* ,stg.groupname,'' || COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' 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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from davincenzo.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='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; -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' order by vacyear; -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,trackername from davincenzo.timetrackerconfig order by trackername -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 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 ttr.*, st.* ,stg.groupname,'' || COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' 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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from davincenzo.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='davincenzo') ttr -where st.isdeleted is null order by groupname,st.staffnumber,surname,prename; -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' order by vacyear; -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='336fcfff-a3e1-4812-3202-24b12653dd1d' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '336fcfff-a3e1-4812-3202-24b12653dd1d' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '336fcfff-a3e1-4812-3202-24b12653dd1d' - 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 davincenzo.staffvacancyyear where id_staff='336fcfff-a3e1-4812-3202-24b12653dd1d' order by vacyear; -t,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='336fcfff-a3e1-4812-3202-24b12653dd1d' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='336fcfff-a3e1-4812-3202-24b12653dd1d' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment, - vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment, - date(date_trunc('week',pd.daydate)) as weekstart, - to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1, - to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1, - to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2, - to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2, - to_char(pd.timepause::interval, 'HH24:MI') AS timepause, - -- coalesce('
' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '
','') AS dspvacancyhours, - to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours, - to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours, - to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours, - to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours, - to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours, - to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours, - to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours, - to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours, - to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours, - to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours, - to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1, - to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1, - to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2, - to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2, - COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata, - COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata, - CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter, - to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours, - to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours, - to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation, - to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours, - max(vd.vacancyname) as vacancyname, - to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime, - interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff, - max(tt.incompletetrack) as incompletetrack - FROM davincenzo.staffreportperioddays pd - JOIN davincenzo.staff st ON pd.id_staff = st.id and st.id='336fcfff-a3e1-4812-3202-24b12653dd1d' and st.isdeleted is null - LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto, - yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval, - date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM davincenzo.staffreportperioddays sr - WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate - left join davincenzo.worktimes wk on pd.daydate between wk.startdate and wk.enddate - cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from davincenzo.worktimes where isdefault =true) wkstd - left join davincenzo.vacancydays vd on pd.daydate=vd.daydate - left join ( - select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime, - sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack -from davincenzo.timetracker where id_staff='336fcfff-a3e1-4812-3202-24b12653dd1d' and daydate between date('2021-01-04') and date('2021-01-04') group by daydate - ) tt on pd.daydate=tt.daydate - WHERE pd.daydate between date('2021-01-04') and date('2021-01-04') - group by pd.id - ORDER BY pd.id_staff, pd.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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment, - vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment, - date(date_trunc('week',pd.daydate)) as weekstart, - to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1, - to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1, - to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2, - to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2, - to_char(pd.timepause::interval, 'HH24:MI') AS timepause, - -- coalesce('
' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '
','') AS dspvacancyhours, - to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours, - to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours, - to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours, - to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours, - to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours, - to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours, - to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours, - to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours, - to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours, - to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours, - to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1, - to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1, - to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2, - to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2, - COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata, - COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata, - CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter, - to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours, - to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours, - to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation, - to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours, - max(vd.vacancyname) as vacancyname, - to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime, - interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff, - max(tt.incompletetrack) as incompletetrack - FROM davincenzo.staffreportperioddays pd - JOIN davincenzo.staff st ON pd.id_staff = st.id and st.id='336fcfff-a3e1-4812-3202-24b12653dd1d' and st.isdeleted is null - LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto, - yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval, - date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM davincenzo.staffreportperioddays sr - WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate - left join davincenzo.worktimes wk on pd.daydate between wk.startdate and wk.enddate - cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from davincenzo.worktimes where isdefault =true) wkstd - left join davincenzo.vacancydays vd on pd.daydate=vd.daydate - left join ( - select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime, - sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack -from davincenzo.timetracker where id_staff='336fcfff-a3e1-4812-3202-24b12653dd1d' and daydate between date('2021-01-04') and date('2021-01-04') group by daydate - ) tt on pd.daydate=tt.daydate - WHERE pd.daydate between date('2021-01-04') and date('2021-01-04') - group by pd.id - ORDER BY pd.id_staff, pd.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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment, - vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment, - date(date_trunc('week',pd.daydate)) as weekstart, - to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1, - to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1, - to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2, - to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2, - to_char(pd.timepause::interval, 'HH24:MI') AS timepause, - -- coalesce('
' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '
','') AS dspvacancyhours, - to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours, - to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours, - to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours, - to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours, - to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours, - to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours, - to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours, - to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours, - to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours, - to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours, - to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1, - to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1, - to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2, - to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2, - COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata, - COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata, - CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter, - to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours, - to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours, - to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation, - to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours, - max(vd.vacancyname) as vacancyname, - to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime, - interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff, - max(tt.incompletetrack) as incompletetrack - FROM davincenzo.staffreportperioddays pd - JOIN davincenzo.staff st ON pd.id_staff = st.id and st.id='336fcfff-a3e1-4812-3202-24b12653dd1d' and st.isdeleted is null - LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto, - yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval, - date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM davincenzo.staffreportperioddays sr - WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate - left join davincenzo.worktimes wk on pd.daydate between wk.startdate and wk.enddate - cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from davincenzo.worktimes where isdefault =true) wkstd - left join davincenzo.vacancydays vd on pd.daydate=vd.daydate - left join ( - select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime, - sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack -from davincenzo.timetracker where id_staff='336fcfff-a3e1-4812-3202-24b12653dd1d' and daydate between date('2021-01-04') and date('2021-01-04') group by daydate - ) tt on pd.daydate=tt.daydate - WHERE pd.daydate between date('2021-01-04') and date('2021-01-04') - group by pd.id - ORDER BY pd.id_staff, pd.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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' order by startdate,enddate; -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' order by vacyear; -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='5eb7a873-83ce-aaf5-1e55-7336da34785f' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '5eb7a873-83ce-aaf5-1e55-7336da34785f' - 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 davincenzo.staffvacancyyear where id_staff='5eb7a873-83ce-aaf5-1e55-7336da34785f' order by vacyear; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='5eb7a873-83ce-aaf5-1e55-7336da34785f' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='5eb7a873-83ce-aaf5-1e55-7336da34785f' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='3465d3a7-a883-624c-f677-17864861a2d5' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '3465d3a7-a883-624c-f677-17864861a2d5' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='3465d3a7-a883-624c-f677-17864861a2d5' order by startdate,enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '3465d3a7-a883-624c-f677-17864861a2d5' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='3465d3a7-a883-624c-f677-17864861a2d5' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='998f0d4b-3e14-6198-53b1-7e117944921e' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '998f0d4b-3e14-6198-53b1-7e117944921e' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='998f0d4b-3e14-6198-53b1-7e117944921e' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '998f0d4b-3e14-6198-53b1-7e117944921e' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='998f0d4b-3e14-6198-53b1-7e117944921e' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='998f0d4b-3e14-6198-53b1-7e117944921e' order by vacyear; -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='3fba3d93-55ff-c3ad-e2c5-0ca83c4d73c5' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='3fba3d93-55ff-c3ad-e2c5-0ca83c4d73c5' order by startdate,enddate; -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '3fba3d93-55ff-c3ad-e2c5-0ca83c4d73c5' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -'g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='3fba3d93-55ff-c3ad-e2c5-0ca83c4d73c5' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='3fba3d93-55ff-c3ad-e2c5-0ca83c4d73c5' order by vacyear; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '3fba3d93-55ff-c3ad-e2c5-0ca83c4d73c5' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='27d13a44-0d65-347a-055b-2e993f5b5561' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='27d13a44-0d65-347a-055b-2e993f5b5561' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '27d13a44-0d65-347a-055b-2e993f5b5561' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='27d13a44-0d65-347a-055b-2e993f5b5561' order by vacyear; -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '27d13a44-0d65-347a-055b-2e993f5b5561' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='27d13a44-0d65-347a-055b-2e993f5b5561' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='410d087c-15c7-6e72-4811-6e44f2056916' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='410d087c-15c7-6e72-4811-6e44f2056916' order by startdate,enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='410d087c-15c7-6e72-4811-6e44f2056916' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '410d087c-15c7-6e72-4811-6e44f2056916' - 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 davincenzo.staffvacancyyear where id_staff='410d087c-15c7-6e72-4811-6e44f2056916' order by vacyear; -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='a924e42f-fdd7-e970-8149-fd8efe26f6e7' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'a924e42f-fdd7-e970-8149-fd8efe26f6e7' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='a924e42f-fdd7-e970-8149-fd8efe26f6e7' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='a924e42f-fdd7-e970-8149-fd8efe26f6e7' order by vacyear; -iod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'a924e42f-fdd7-e970-8149-fd8efe26f6e7' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='a924e42f-fdd7-e970-8149-fd8efe26f6e7' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='2766f26a-74e7-09fd-e44d-e41d501fcad9' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='2766f26a-74e7-09fd-e44d-e41d501fcad9' order by startdate,enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '2766f26a-74e7-09fd-e44d-e41d501fcad9' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '2766f26a-74e7-09fd-e44d-e41d501fcad9' - 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 davincenzo.staffvacancyyear where id_staff='2766f26a-74e7-09fd-e44d-e41d501fcad9' order by vacyear; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='2766f26a-74e7-09fd-e44d-e41d501fcad9' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='a49dadd1-15dc-30ef-38bb-3ccb2190fab2' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'a49dadd1-15dc-30ef-38bb-3ccb2190fab2' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='a49dadd1-15dc-30ef-38bb-3ccb2190fab2' order by startdate,enddate; -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'a49dadd1-15dc-30ef-38bb-3ccb2190fab2' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='a49dadd1-15dc-30ef-38bb-3ccb2190fab2' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='a49dadd1-15dc-30ef-38bb-3ccb2190fab2' order by vacyear; -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='af7bf290-b154-0f7b-4484-05bec10ea033' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'af7bf290-b154-0f7b-4484-05bec10ea033' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='af7bf290-b154-0f7b-4484-05bec10ea033' order by startdate,enddate; -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'af7bf290-b154-0f7b-4484-05bec10ea033' - 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 davincenzo.staffvacancyyear where id_staff='af7bf290-b154-0f7b-4484-05bec10ea033' order by vacyear; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='af7bf290-b154-0f7b-4484-05bec10ea033' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='f040d6d0-4507-91e2-6d93-157be0727255' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='f040d6d0-4507-91e2-6d93-157be0727255' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f040d6d0-4507-91e2-6d93-157be0727255' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='f040d6d0-4507-91e2-6d93-157be0727255' order by vacyear; -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f040d6d0-4507-91e2-6d93-157be0727255' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='7ec669d5-b348-1523-2768-2339e1f83b70' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '7ec669d5-b348-1523-2768-2339e1f83b70' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -8-1523-2768-2339e1f83b70' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='7ec669d5-b348-1523-2768-2339e1f83b70' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='7ec669d5-b348-1523-2768-2339e1f83b70' order by vacyear; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='7ec669d5-b348-1523-2768-2339e1f83b70' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='f040d6d0-4507-91e2-6d93-157be0727255' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f040d6d0-4507-91e2-6d93-157be0727255' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='f040d6d0-4507-91e2-6d93-157be0727255' order by vacyear; -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f040d6d0-4507-91e2-6d93-157be0727255' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='f040d6d0-4507-91e2-6d93-157be0727255' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='f040d6d0-4507-91e2-6d93-157be0727255' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='5d020c34-f057-5b13-e47e-7ce73003e230' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='5d020c34-f057-5b13-e47e-7ce73003e230' order by startdate,enddate; -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '5d020c34-f057-5b13-e47e-7ce73003e230' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '5d020c34-f057-5b13-e47e-7ce73003e230' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='5d020c34-f057-5b13-e47e-7ce73003e230' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='5d020c34-f057-5b13-e47e-7ce73003e230' order by vacyear; -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='327be400-18a2-cdc7-898a-c8b5c3c3b0ee' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='327be400-18a2-cdc7-898a-c8b5c3c3b0ee' 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 davincenzo.staffcontract where id_staff='327be400-18a2-cdc7-898a-c8b5c3c3b0ee' order by startdate,enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='327be400-18a2-cdc7-898a-c8b5c3c3b0ee' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '327be400-18a2-cdc7-898a-c8b5c3c3b0ee' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '327be400-18a2-cdc7-898a-c8b5c3c3b0ee' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='4629f3cf-35ec-ac5b-28f7-42a4faa4d3f2' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '4629f3cf-35ec-ac5b-28f7-42a4faa4d3f2' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='4629f3cf-35ec-ac5b-28f7-42a4faa4d3f2' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='4629f3cf-35ec-ac5b-28f7-42a4faa4d3f2' order by vacyear; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '4629f3cf-35ec-ac5b-28f7-42a4faa4d3f2' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='4629f3cf-35ec-ac5b-28f7-42a4faa4d3f2' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='63d25b04-0486-d233-f145-377054ba5d11' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '63d25b04-0486-d233-f145-377054ba5d11' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '63d25b04-0486-d233-f145-377054ba5d11' - 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 davincenzo.staffvacancyyear where id_staff='63d25b04-0486-d233-f145-377054ba5d11' 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 davincenzo.staffcontract where id_staff='63d25b04-0486-d233-f145-377054ba5d11' order by startdate,enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='63d25b04-0486-d233-f145-377054ba5d11' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='a49dadd1-15dc-30ef-38bb-3ccb2190fab2' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='a49dadd1-15dc-30ef-38bb-3ccb2190fab2' order by vacyear; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'a49dadd1-15dc-30ef-38bb-3ccb2190fab2' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='a49dadd1-15dc-30ef-38bb-3ccb2190fab2' order by startdate,enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='a49dadd1-15dc-30ef-38bb-3ccb2190fab2' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'a49dadd1-15dc-30ef-38bb-3ccb2190fab2' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='2766f26a-74e7-09fd-e44d-e41d501fcad9' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '2766f26a-74e7-09fd-e44d-e41d501fcad9' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='2766f26a-74e7-09fd-e44d-e41d501fcad9' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='2766f26a-74e7-09fd-e44d-e41d501fcad9' 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 davincenzo.staffcontract where id_staff='2766f26a-74e7-09fd-e44d-e41d501fcad9' order by startdate,enddate; -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '2766f26a-74e7-09fd-e44d-e41d501fcad9' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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'; - || 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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and date_trunc('year',spd.daydate)=date_trunc('year',date('2022-01-01')) - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: 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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and date_trunc('year',spd.daydate)=date_trunc('year',date('2022-01-01')) - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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.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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,trackername from davincenzo.timetrackerconfig order by trackername -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 ttr.*, st.* ,stg.groupname,'' || COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' 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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from davincenzo.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='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; -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' order by vacyear; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment, - vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment, - date(date_trunc('week',pd.daydate)) as weekstart, - to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1, - to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1, - to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2, - to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2, - to_char(pd.timepause::interval, 'HH24:MI') AS timepause, - -- coalesce('
' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '
','') AS dspvacancyhours, - to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours, - to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours, - to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours, - to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours, - to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours, - to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours, - to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours, - to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours, - to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours, - to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours, - to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1, - to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1, - to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2, - to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2, - COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata, - COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata, - CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter, - to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours, - to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours, - to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation, - to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours, - max(vd.vacancyname) as vacancyname, - to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime, - interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff, - max(tt.incompletetrack) as incompletetrack - FROM davincenzo.staffreportperioddays pd - JOIN davincenzo.staff st ON pd.id_staff = st.id and st.id='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' and st.isdeleted is null - LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto, - yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval, - date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM davincenzo.staffreportperioddays sr - WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate - left join davincenzo.worktimes wk on pd.daydate between wk.startdate and wk.enddate - cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from davincenzo.worktimes where isdefault =true) wkstd - left join davincenzo.vacancydays vd on pd.daydate=vd.daydate - left join ( - select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime, - sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack -from davincenzo.timetracker where id_staff='1f2b91e5-2ac4-509c-b054-ec7f5a22e0c3' and daydate between date('2021-01-04') and date('2021-01-04') group by daydate - ) tt on pd.daydate=tt.daydate - WHERE pd.daydate between date('2021-01-04') and date('2021-01-04') - group by pd.id - ORDER BY pd.id_staff, pd.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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='336fcfff-a3e1-4812-3202-24b12653dd1d' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '336fcfff-a3e1-4812-3202-24b12653dd1d' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='336fcfff-a3e1-4812-3202-24b12653dd1d' order by startdate,enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '336fcfff-a3e1-4812-3202-24b12653dd1d' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='336fcfff-a3e1-4812-3202-24b12653dd1d' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='336fcfff-a3e1-4812-3202-24b12653dd1d' order by vacyear; -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='5eb7a873-83ce-aaf5-1e55-7336da34785f' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='5eb7a873-83ce-aaf5-1e55-7336da34785f' order by vacyear; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='5eb7a873-83ce-aaf5-1e55-7336da34785f' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '5eb7a873-83ce-aaf5-1e55-7336da34785f' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '5eb7a873-83ce-aaf5-1e55-7336da34785f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='3465d3a7-a883-624c-f677-17864861a2d5' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '3465d3a7-a883-624c-f677-17864861a2d5' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -3-624c-f677-17864861a2d5' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='3465d3a7-a883-624c-f677-17864861a2d5' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='3465d3a7-a883-624c-f677-17864861a2d5' order by vacyear; -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='998f0d4b-3e14-6198-53b1-7e117944921e' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='998f0d4b-3e14-6198-53b1-7e117944921e' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='998f0d4b-3e14-6198-53b1-7e117944921e' order by vacyear; -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '998f0d4b-3e14-6198-53b1-7e117944921e' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='998f0d4b-3e14-6198-53b1-7e117944921e' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='3fba3d93-55ff-c3ad-e2c5-0ca83c4d73c5' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='3fba3d93-55ff-c3ad-e2c5-0ca83c4d73c5' 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 davincenzo.staffcontract where id_staff='3fba3d93-55ff-c3ad-e2c5-0ca83c4d73c5' order by startdate,enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '3fba3d93-55ff-c3ad-e2c5-0ca83c4d73c5' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '3fba3d93-55ff-c3ad-e2c5-0ca83c4d73c5' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='3fba3d93-55ff-c3ad-e2c5-0ca83c4d73c5' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='27d13a44-0d65-347a-055b-2e993f5b5561' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '27d13a44-0d65-347a-055b-2e993f5b5561' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '27d13a44-0d65-347a-055b-2e993f5b5561' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='27d13a44-0d65-347a-055b-2e993f5b5561' order by startdate,enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='27d13a44-0d65-347a-055b-2e993f5b5561' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='27d13a44-0d65-347a-055b-2e993f5b5561' order by vacyear; -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='27d13a44-0d65-347a-055b-2e993f5b5561' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='27d13a44-0d65-347a-055b-2e993f5b5561' order by vacyear; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='27d13a44-0d65-347a-055b-2e993f5b5561' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='27d13a44-0d65-347a-055b-2e993f5b5561' order by startdate,enddate; -yhours, '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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '27d13a44-0d65-347a-055b-2e993f5b5561' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '27d13a44-0d65-347a-055b-2e993f5b5561' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='410d087c-15c7-6e72-4811-6e44f2056916' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '410d087c-15c7-6e72-4811-6e44f2056916' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '410d087c-15c7-6e72-4811-6e44f2056916' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -'g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='410d087c-15c7-6e72-4811-6e44f2056916' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='410d087c-15c7-6e72-4811-6e44f2056916' 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 davincenzo.staffcontract where id_staff='410d087c-15c7-6e72-4811-6e44f2056916' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='a924e42f-fdd7-e970-8149-fd8efe26f6e7' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='a924e42f-fdd7-e970-8149-fd8efe26f6e7' order by startdate,enddate; -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'a924e42f-fdd7-e970-8149-fd8efe26f6e7' - 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 davincenzo.staffvacancyyear where id_staff='a924e42f-fdd7-e970-8149-fd8efe26f6e7' order by vacyear; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='a924e42f-fdd7-e970-8149-fd8efe26f6e7' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'a924e42f-fdd7-e970-8149-fd8efe26f6e7' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='2766f26a-74e7-09fd-e44d-e41d501fcad9' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='2766f26a-74e7-09fd-e44d-e41d501fcad9' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '2766f26a-74e7-09fd-e44d-e41d501fcad9' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='2766f26a-74e7-09fd-e44d-e41d501fcad9' order by vacyear; -har(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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '2766f26a-74e7-09fd-e44d-e41d501fcad9' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='2766f26a-74e7-09fd-e44d-e41d501fcad9' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='a49dadd1-15dc-30ef-38bb-3ccb2190fab2' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='a49dadd1-15dc-30ef-38bb-3ccb2190fab2' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='a49dadd1-15dc-30ef-38bb-3ccb2190fab2' order by vacyear; -iod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'a49dadd1-15dc-30ef-38bb-3ccb2190fab2' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='a49dadd1-15dc-30ef-38bb-3ccb2190fab2' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'a49dadd1-15dc-30ef-38bb-3ccb2190fab2' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='af7bf290-b154-0f7b-4484-05bec10ea033' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='af7bf290-b154-0f7b-4484-05bec10ea033' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='af7bf290-b154-0f7b-4484-05bec10ea033' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='af7bf290-b154-0f7b-4484-05bec10ea033' order by vacyear; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'af7bf290-b154-0f7b-4484-05bec10ea033' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -4-0f7b-4484-05bec10ea033' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='f040d6d0-4507-91e2-6d93-157be0727255' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='f040d6d0-4507-91e2-6d93-157be0727255' order by startdate,enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='f040d6d0-4507-91e2-6d93-157be0727255' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f040d6d0-4507-91e2-6d93-157be0727255' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f040d6d0-4507-91e2-6d93-157be0727255' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from davincenzo.staffvacancyyear where id_staff='f040d6d0-4507-91e2-6d93-157be0727255' order by vacyear; -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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from davincenzo.staff where id='7ec669d5-b348-1523-2768-2339e1f83b70' 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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= '43f12ac7-30fb-7598-d64a-635bc32525a7' 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/100.0.4896.88 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 davincenzo.staffreportperiod srp - LEFT JOIN davincenzo.staff st ON srp.id_staff = st.id - LEFT JOIN davincenzo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '7ec669d5-b348-1523-2768-2339e1f83b70' - 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 davincenzo.staffvacancyyear where id_staff='7ec669d5-b348-1523-2768-2339e1f83b70' order by vacyear; -iod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from davincenzo.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from davincenzo.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join davincenzo.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join davincenzo.reportperiod rp on (rp.id=srp.id_reportperiod) - join davincenzo.staff st on (pd.id_staff=st.id) - LEFT JOIN davincenzo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '7ec669d5-b348-1523-2768-2339e1f83b70' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from davincenzo.staffreportperioddays spd - join davincenzo.staff st on (st.id=spd.id_staff) - join davincenzo.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='7ec669d5-b348-1523-2768-2339e1f83b70' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from davincenzo.staffcontract where id_staff='7ec669d5-b348-1523-2768-2339e1f83b70' order by startdate,enddate; -QUERY: select us.id,cp.schemata from public.users us left join public.companies cp on (us.id_company=cp.id) where lower(us.username)=lower('ksaffran@dks.lu') and us.userpassword = 'a1b496fa520a1c52edd076ca7a59e56667e7ebeb5ba5ba966d2d01628e165359' and us.isblocked is null; -EXEC: delete from public.sessions where id_user='e9e6880b-75c7-70b5-ce61-49cf6d62630f' and remote_addr='::1' and user_agent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36'; -QUERY: insert into public.sessions (id_user,id,remote_addr,user_agent,sessiondata) VALUES( 'e9e6880b-75c7-70b5-ce61-49cf6d62630f',public.getuuid(), '::1','Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36',('{"schemata":"demo"}'::text)::json) returning 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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'; - || 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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: 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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,trackername from demo.timetrackerconfig order by trackername -QUERYARRAY: select sg.id,sg.groupname,sg.groupcolor,sg.isdefault,COALESCE(count(st.id), 0) AS staffmembers FROM demo.staffgroups sg LEFT JOIN demo.staff st ON (st.id_staffgroup = sg.id) WHERE st.isdeleted IS NULL GROUP BY sg.id ORDER BY sg.groupname; -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 demo.workplans wp - ORDER BY wp.isdefault, wp.workplan; -QUERYARRAY: select ttr.*, st.* ,stg.groupname,'' || COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' AS staffname,sc.staffstatus from demo.staff st -LEFT JOIN demo.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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from demo.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='demo') ttr -where st.isdeleted is null order by groupname,st.staffnumber,surname,prename; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: 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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select sessiondata from public.sessions where id='10f82f19-8c2f-8ce0-394d-72562bffac59' -EXEC: update public.sessions set sessiondata='{"schemata":"alicehartmann"}' where id='10f82f19-8c2f-8ce0-394d-72562bffac59' -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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.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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from alicehartmann.staffreportperioddays spd - join alicehartmann.staff st on (st.id=spd.id_staff) - join alicehartmann.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and date_trunc('year',spd.daydate)=date_trunc('year',date('2022-01-01')) - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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.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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select sessiondata from public.sessions where id='10f82f19-8c2f-8ce0-394d-72562bffac59' -EXEC: update public.sessions set sessiondata='{"schemata":"kraeltgen"}' where id='10f82f19-8c2f-8ce0-394d-72562bffac59' -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: 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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' 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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from kraeltgen.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='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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='7969b272-ba37-e27a-b374-f8ae12278a7f' 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '7969b272-ba37-e27a-b374-f8ae12278a7f' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='7969b272-ba37-e27a-b374-f8ae12278a7f' order by vacyear; -_staff='7969b272-ba37-e27a-b374-f8ae12278a7f' order by startdate,enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='7969b272-ba37-e27a-b374-f8ae12278a7f' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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 = '7969b272-ba37-e27a-b374-f8ae12278a7f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '7969b272-ba37-e27a-b374-f8ae12278a7f' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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 = '7969b272-ba37-e27a-b374-f8ae12278a7f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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 = '7969b272-ba37-e27a-b374-f8ae12278a7f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '7969b272-ba37-e27a-b374-f8ae12278a7f' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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.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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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 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 id,trackername from kraeltgen.timetrackerconfig order by trackername -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 ttr.*, st.* ,stg.groupname,'' || COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' 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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from kraeltgen.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='kraeltgen') ttr -where st.isdeleted is null order by groupname,st.staffnumber,surname,prename; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='7969b272-ba37-e27a-b374-f8ae12278a7f' 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='7969b272-ba37-e27a-b374-f8ae12278a7f' order by vacyear; -_staff='7969b272-ba37-e27a-b374-f8ae12278a7f' order by startdate,enddate; -cyhours, '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 = '7969b272-ba37-e27a-b374-f8ae12278a7f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='7969b272-ba37-e27a-b374-f8ae12278a7f' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '7969b272-ba37-e27a-b374-f8ae12278a7f' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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 = '7969b272-ba37-e27a-b374-f8ae12278a7f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '7969b272-ba37-e27a-b374-f8ae12278a7f' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='3cbeee64-9c38-7880-c758-45518dcf800e' 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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 = '3cbeee64-9c38-7880-c758-45518dcf800e' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '3cbeee64-9c38-7880-c758-45518dcf800e' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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='3cbeee64-9c38-7880-c758-45518dcf800e' order by startdate,enddate; -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 = '3cbeee64-9c38-7880-c758-45518dcf800e' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='3cbeee64-9c38-7880-c758-45518dcf800e' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='3cbeee64-9c38-7880-c758-45518dcf800e' order by vacyear; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '3cbeee64-9c38-7880-c758-45518dcf800e' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='20b53171-4182-d837-21b7-33ef52d49329' 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -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='20b53171-4182-d837-21b7-33ef52d49329' order by startdate,enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='20b53171-4182-d837-21b7-33ef52d49329' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '20b53171-4182-d837-21b7-33ef52d49329' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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 = '20b53171-4182-d837-21b7-33ef52d49329' - 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='20b53171-4182-d837-21b7-33ef52d49329' order by vacyear; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '20b53171-4182-d837-21b7-33ef52d49329' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='73f003c0-4912-7c00-e38a-ce42f36bbbfb' 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='73f003c0-4912-7c00-e38a-ce42f36bbbfb' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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 = '73f003c0-4912-7c00-e38a-ce42f36bbbfb' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -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='73f003c0-4912-7c00-e38a-ce42f36bbbfb' order by startdate,enddate; -ddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '73f003c0-4912-7c00-e38a-ce42f36bbbfb' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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 = '73f003c0-4912-7c00-e38a-ce42f36bbbfb' - 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='73f003c0-4912-7c00-e38a-ce42f36bbbfb' order by vacyear; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '73f003c0-4912-7c00-e38a-ce42f36bbbfb' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='087ed140-8731-0792-70d1-e92e2505c44b' 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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 = '087ed140-8731-0792-70d1-e92e2505c44b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '087ed140-8731-0792-70d1-e92e2505c44b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='087ed140-8731-0792-70d1-e92e2505c44b' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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 = '087ed140-8731-0792-70d1-e92e2505c44b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -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='087ed140-8731-0792-70d1-e92e2505c44b' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='087ed140-8731-0792-70d1-e92e2505c44b' order by vacyear; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '087ed140-8731-0792-70d1-e92e2505c44b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='a3ae61bb-a890-70cf-97a5-f3379f446d1e' 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'a3ae61bb-a890-70cf-97a5-f3379f446d1e' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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 = 'a3ae61bb-a890-70cf-97a5-f3379f446d1e' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -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 = 'a3ae61bb-a890-70cf-97a5-f3379f446d1e' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -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='a3ae61bb-a890-70cf-97a5-f3379f446d1e' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='a3ae61bb-a890-70cf-97a5-f3379f446d1e' order by vacyear; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='a3ae61bb-a890-70cf-97a5-f3379f446d1e' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'a3ae61bb-a890-70cf-97a5-f3379f446d1e' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='087ed140-8731-0792-70d1-e92e2505c44b' 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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 = '087ed140-8731-0792-70d1-e92e2505c44b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -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='087ed140-8731-0792-70d1-e92e2505c44b' order by startdate,enddate; -ddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '087ed140-8731-0792-70d1-e92e2505c44b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='087ed140-8731-0792-70d1-e92e2505c44b' order by vacyear; -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 = '087ed140-8731-0792-70d1-e92e2505c44b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='087ed140-8731-0792-70d1-e92e2505c44b' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '087ed140-8731-0792-70d1-e92e2505c44b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERY: select * from kraeltgen.staff where id='73f003c0-4912-7c00-e38a-ce42f36bbbfb' 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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 = '73f003c0-4912-7c00-e38a-ce42f36bbbfb' - 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='73f003c0-4912-7c00-e38a-ce42f36bbbfb' order by vacyear; -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 = '73f003c0-4912-7c00-e38a-ce42f36bbbfb' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '73f003c0-4912-7c00-e38a-ce42f36bbbfb' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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='73f003c0-4912-7c00-e38a-ce42f36bbbfb' order by startdate,enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='73f003c0-4912-7c00-e38a-ce42f36bbbfb' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '73f003c0-4912-7c00-e38a-ce42f36bbbfb' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '73f003c0-4912-7c00-e38a-ce42f36bbbfb' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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 = '73f003c0-4912-7c00-e38a-ce42f36bbbfb' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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 = '73f003c0-4912-7c00-e38a-ce42f36bbbfb' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '73f003c0-4912-7c00-e38a-ce42f36bbbfb' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '73f003c0-4912-7c00-e38a-ce42f36bbbfb' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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 = '73f003c0-4912-7c00-e38a-ce42f36bbbfb' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '73f003c0-4912-7c00-e38a-ce42f36bbbfb' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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 = '73f003c0-4912-7c00-e38a-ce42f36bbbfb' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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 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 id,trackername from kraeltgen.timetrackerconfig order by trackername -QUERYARRAY: select ttr.*, st.* ,stg.groupname,'' || COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' 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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from kraeltgen.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='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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='7969b272-ba37-e27a-b374-f8ae12278a7f' 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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 = '7969b272-ba37-e27a-b374-f8ae12278a7f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='7969b272-ba37-e27a-b374-f8ae12278a7f' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='7969b272-ba37-e27a-b374-f8ae12278a7f' 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='7969b272-ba37-e27a-b374-f8ae12278a7f' 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='3cbeee64-9c38-7880-c758-45518dcf800e' 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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 = '3cbeee64-9c38-7880-c758-45518dcf800e' - 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='3cbeee64-9c38-7880-c758-45518dcf800e' order by vacyear; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '3cbeee64-9c38-7880-c758-45518dcf800e' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='3cbeee64-9c38-7880-c758-45518dcf800e' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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='3cbeee64-9c38-7880-c758-45518dcf800e' 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='20b53171-4182-d837-21b7-33ef52d49329' 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '20b53171-4182-d837-21b7-33ef52d49329' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='20b53171-4182-d837-21b7-33ef52d49329' order by vacyear; -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 = '20b53171-4182-d837-21b7-33ef52d49329' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='20b53171-4182-d837-21b7-33ef52d49329' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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='20b53171-4182-d837-21b7-33ef52d49329' 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='f94fd7b0-6921-c0a0-7e69-08fe1175ba9b' 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -EXEC: UPDATE kraeltgen.staff SET color=null WHERE id='20b53171-4182-d837-21b7-33ef52d49329'; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f94fd7b0-6921-c0a0-7e69-08fe1175ba9b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='f94fd7b0-6921-c0a0-7e69-08fe1175ba9b' 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='f94fd7b0-6921-c0a0-7e69-08fe1175ba9b' order by startdate,enddate; -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 = 'f94fd7b0-6921-c0a0-7e69-08fe1175ba9b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='f94fd7b0-6921-c0a0-7e69-08fe1175ba9b' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select ttr.*, st.* ,stg.groupname,'' || COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' 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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from kraeltgen.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='kraeltgen') ttr -where st.isdeleted is null order by groupname,st.staffnumber,surname,prename; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -EXEC: UPDATE kraeltgen.staff SET color=null WHERE id='f94fd7b0-6921-c0a0-7e69-08fe1175ba9b'; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select ttr.*, st.* ,stg.groupname,'' || COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' 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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from kraeltgen.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='kraeltgen') ttr -where st.isdeleted is null order by groupname,st.staffnumber,surname,prename; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='f94fd7b0-6921-c0a0-7e69-08fe1175ba9b' 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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 = 'f94fd7b0-6921-c0a0-7e69-08fe1175ba9b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f94fd7b0-6921-c0a0-7e69-08fe1175ba9b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -I') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='f94fd7b0-6921-c0a0-7e69-08fe1175ba9b' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='f94fd7b0-6921-c0a0-7e69-08fe1175ba9b' 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='f94fd7b0-6921-c0a0-7e69-08fe1175ba9b' 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f94fd7b0-6921-c0a0-7e69-08fe1175ba9b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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 = 'f94fd7b0-6921-c0a0-7e69-08fe1175ba9b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours,sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f94fd7b0-6921-c0a0-7e69-08fe1175ba9b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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 = 'f94fd7b0-6921-c0a0-7e69-08fe1175ba9b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: 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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '10f82f19-8c2f-8ce0-394d-72562bffac59' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and date_trunc('year',spd.daydate)=date_trunc('year',date('2022-01-01')) - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERY: select us.id,cp.schemata from public.users us left join public.companies cp on (us.id_company=cp.id) where lower(us.username)=lower('ksaffran@dks.lu') and us.userpassword = 'a1b496fa520a1c52edd076ca7a59e56667e7ebeb5ba5ba966d2d01628e165359' and us.isblocked is null; -EXEC: delete from public.sessions where id_user='e9e6880b-75c7-70b5-ce61-49cf6d62630f' and remote_addr='::1' and user_agent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36'; -QUERY: insert into public.sessions (id_user,id,remote_addr,user_agent,sessiondata) VALUES( 'e9e6880b-75c7-70b5-ce61-49cf6d62630f',public.getuuid(), '::1','Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36',('{"schemata":"demo"}'::text)::json) returning 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= 'fe03ee7e-121b-de54-e818-83c89c9feb96' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= 'fe03ee7e-121b-de54-e818-83c89c9feb96' 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/100.0.4896.88 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= 'fe03ee7e-121b-de54-e818-83c89c9feb96' 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/100.0.4896.88 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= 'fe03ee7e-121b-de54-e818-83c89c9feb96' 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/100.0.4896.88 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= 'fe03ee7e-121b-de54-e818-83c89c9feb96' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= 'fe03ee7e-121b-de54-e818-83c89c9feb96' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= 'fe03ee7e-121b-de54-e818-83c89c9feb96' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= 'fe03ee7e-121b-de54-e818-83c89c9feb96' 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/100.0.4896.88 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= 'fe03ee7e-121b-de54-e818-83c89c9feb96' 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/100.0.4896.88 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.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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= 'fe03ee7e-121b-de54-e818-83c89c9feb96' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= 'fe03ee7e-121b-de54-e818-83c89c9feb96' 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/100.0.4896.88 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= 'fe03ee7e-121b-de54-e818-83c89c9feb96' 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/100.0.4896.88 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= 'fe03ee7e-121b-de54-e818-83c89c9feb96' 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/100.0.4896.88 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= 'fe03ee7e-121b-de54-e818-83c89c9feb96' 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/100.0.4896.88 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= 'fe03ee7e-121b-de54-e818-83c89c9feb96' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= 'fe03ee7e-121b-de54-e818-83c89c9feb96' 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/100.0.4896.88 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= 'fe03ee7e-121b-de54-e818-83c89c9feb96' 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/100.0.4896.88 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= 'fe03ee7e-121b-de54-e818-83c89c9feb96' 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/100.0.4896.88 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= 'fe03ee7e-121b-de54-e818-83c89c9feb96' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= 'fe03ee7e-121b-de54-e818-83c89c9feb96' 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/100.0.4896.88 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= 'fe03ee7e-121b-de54-e818-83c89c9feb96' 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/100.0.4896.88 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= 'fe03ee7e-121b-de54-e818-83c89c9feb96' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= 'fe03ee7e-121b-de54-e818-83c89c9feb96' 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/100.0.4896.88 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= 'fe03ee7e-121b-de54-e818-83c89c9feb96' 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/100.0.4896.88 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.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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= 'fe03ee7e-121b-de54-e818-83c89c9feb96' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select sessiondata from public.sessions where id='fe03ee7e-121b-de54-e818-83c89c9feb96' -EXEC: update public.sessions set sessiondata='{"schemata":"kraeltgen"}' where id='fe03ee7e-121b-de54-e818-83c89c9feb96' -QUERY: select us.id,cp.schemata from public.users us left join public.companies cp on (us.id_company=cp.id) where lower(us.username)=lower('ksaffran@dks.lu') and us.userpassword = 'a1b496fa520a1c52edd076ca7a59e56667e7ebeb5ba5ba966d2d01628e165359' and us.isblocked is null; -EXEC: delete from public.sessions where id_user='e9e6880b-75c7-70b5-ce61-49cf6d62630f' and remote_addr='::1' and user_agent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36'; -QUERY: insert into public.sessions (id_user,id,remote_addr,user_agent,sessiondata) VALUES( 'e9e6880b-75c7-70b5-ce61-49cf6d62630f',public.getuuid(), '::1','Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36',('{"schemata":"demo"}'::text)::json) returning 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= '2a511bc6-2f35-a0cc-2f28-b96294f8cd2b' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= '2a511bc6-2f35-a0cc-2f28-b96294f8cd2b' 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/100.0.4896.88 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= '2a511bc6-2f35-a0cc-2f28-b96294f8cd2b' 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/100.0.4896.88 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= '2a511bc6-2f35-a0cc-2f28-b96294f8cd2b' 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/100.0.4896.88 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= '2a511bc6-2f35-a0cc-2f28-b96294f8cd2b' 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/100.0.4896.88 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= '2a511bc6-2f35-a0cc-2f28-b96294f8cd2b' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= '2a511bc6-2f35-a0cc-2f28-b96294f8cd2b' 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/100.0.4896.88 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= '2a511bc6-2f35-a0cc-2f28-b96294f8cd2b' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= '2a511bc6-2f35-a0cc-2f28-b96294f8cd2b' 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/100.0.4896.88 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= '2a511bc6-2f35-a0cc-2f28-b96294f8cd2b' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: 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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '2a511bc6-2f35-a0cc-2f28-b96294f8cd2b' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -EXEC: UPDATE public.users set lang='fr' WHERE id='e9e6880b-75c7-70b5-ce61-49cf6d62630f'; -QUERY: select us.id,cp.schemata from public.users us left join public.companies cp on (us.id_company=cp.id) where lower(us.username)=lower('ksaffran@dks.lu') and us.userpassword = 'a1b496fa520a1c52edd076ca7a59e56667e7ebeb5ba5ba966d2d01628e165359' and us.isblocked is null; -EXEC: delete from public.sessions where id_user='e9e6880b-75c7-70b5-ce61-49cf6d62630f' and remote_addr='::1' and user_agent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36'; -QUERY: insert into public.sessions (id_user,id,remote_addr,user_agent,sessiondata) VALUES( 'e9e6880b-75c7-70b5-ce61-49cf6d62630f',public.getuuid(), '::1','Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36',('{"schemata":"demo"}'::text)::json) returning 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= '3513ea81-fdc9-8241-7eb5-abe4684ac3c1' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= '3513ea81-fdc9-8241-7eb5-abe4684ac3c1' 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/100.0.4896.88 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= '3513ea81-fdc9-8241-7eb5-abe4684ac3c1' 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/100.0.4896.88 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= '3513ea81-fdc9-8241-7eb5-abe4684ac3c1' 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/100.0.4896.88 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= '3513ea81-fdc9-8241-7eb5-abe4684ac3c1' 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/100.0.4896.88 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= '3513ea81-fdc9-8241-7eb5-abe4684ac3c1' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= '3513ea81-fdc9-8241-7eb5-abe4684ac3c1' 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/100.0.4896.88 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= '3513ea81-fdc9-8241-7eb5-abe4684ac3c1' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= '3513ea81-fdc9-8241-7eb5-abe4684ac3c1' 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/100.0.4896.88 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= '3513ea81-fdc9-8241-7eb5-abe4684ac3c1' 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/100.0.4896.88 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.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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '3513ea81-fdc9-8241-7eb5-abe4684ac3c1' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select sessiondata from public.sessions where id='3513ea81-fdc9-8241-7eb5-abe4684ac3c1' -EXEC: update public.sessions set sessiondata='{"schemata":"kraeltgen"}' where id='3513ea81-fdc9-8241-7eb5-abe4684ac3c1' -QUERY: select us.id,cp.schemata from public.users us left join public.companies cp on (us.id_company=cp.id) where lower(us.username)=lower('ksaffran@dks.lu') and us.userpassword = 'a1b496fa520a1c52edd076ca7a59e56667e7ebeb5ba5ba966d2d01628e165359' and us.isblocked is null; -EXEC: delete from public.sessions where id_user='e9e6880b-75c7-70b5-ce61-49cf6d62630f' and remote_addr='::1' and user_agent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36'; -QUERY: insert into public.sessions (id_user,id,remote_addr,user_agent,sessiondata) VALUES( 'e9e6880b-75c7-70b5-ce61-49cf6d62630f',public.getuuid(), '::1','Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36',('{"schemata":"demo"}'::text)::json) returning 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: 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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: 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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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 demo.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 demo.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM demo.staffreportperiod srp - LEFT JOIN demo.staff st ON srp.id_staff = st.id - LEFT JOIN demo.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN demo.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = '2583c916-2d07-f42d-9c85-18ee42959317' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='demo'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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.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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select sessiondata from public.sessions where id='6cfa9047-f585-a84b-62b0-0e0a53c9fd08' -EXEC: update public.sessions set sessiondata='{"schemata":"kraeltgen"}' where id='6cfa9047-f585-a84b-62b0-0e0a53c9fd08' -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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.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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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 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 id,trackername from kraeltgen.timetrackerconfig order by trackername -QUERYARRAY: select ttr.*, st.* ,stg.groupname,'' || COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' 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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from kraeltgen.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='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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='20b53171-4182-d837-21b7-33ef52d49329' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='20b53171-4182-d837-21b7-33ef52d49329' 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='20b53171-4182-d837-21b7-33ef52d49329' order by startdate,enddate; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '20b53171-4182-d837-21b7-33ef52d49329' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '20b53171-4182-d837-21b7-33ef52d49329' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='20b53171-4182-d837-21b7-33ef52d49329' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '20b53171-4182-d837-21b7-33ef52d49329' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '20b53171-4182-d837-21b7-33ef52d49329' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='73f003c0-4912-7c00-e38a-ce42f36bbbfb' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -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='73f003c0-4912-7c00-e38a-ce42f36bbbfb' order by startdate,enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='73f003c0-4912-7c00-e38a-ce42f36bbbfb' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '73f003c0-4912-7c00-e38a-ce42f36bbbfb' - 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='73f003c0-4912-7c00-e38a-ce42f36bbbfb' order by vacyear; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '73f003c0-4912-7c00-e38a-ce42f36bbbfb' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '73f003c0-4912-7c00-e38a-ce42f36bbbfb' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - 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='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' 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='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' order by startdate,enddate; -ddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='97648c64-05b7-516a-48a2-23d31511451a' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -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='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='97648c64-05b7-516a-48a2-23d31511451a' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '97648c64-05b7-516a-48a2-23d31511451a' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by vacyear; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '97648c64-05b7-516a-48a2-23d31511451a' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '97648c64-05b7-516a-48a2-23d31511451a' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '97648c64-05b7-516a-48a2-23d31511451a' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '97648c64-05b7-516a-48a2-23d31511451a' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '97648c64-05b7-516a-48a2-23d31511451a' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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 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; -ce(st.job,'') || '' 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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from kraeltgen.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='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; -QUERYARRAY: select id,trackername from kraeltgen.timetrackerconfig order by trackername -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -en mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' order by vacyear; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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 ttr.*, st.* ,stg.groupname,'' || COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' 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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from kraeltgen.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='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; -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; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='97648c64-05b7-516a-48a2-23d31511451a' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='97648c64-05b7-516a-48a2-23d31511451a' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -cyhours, '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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - 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='97648c64-05b7-516a-48a2-23d31511451a' order by vacyear; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '97648c64-05b7-516a-48a2-23d31511451a' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '97648c64-05b7-516a-48a2-23d31511451a' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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.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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' 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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from kraeltgen.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='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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' order by vacyear; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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 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 id,trackername from kraeltgen.timetrackerconfig order by trackername -QUERYARRAY: select ttr.*, st.* ,stg.groupname,'' || COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' 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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from kraeltgen.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='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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' 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='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' order by startdate,enddate; -cyhours, '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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='087ed140-8731-0792-70d1-e92e2505c44b' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '087ed140-8731-0792-70d1-e92e2505c44b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -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='087ed140-8731-0792-70d1-e92e2505c44b' order by startdate,enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='087ed140-8731-0792-70d1-e92e2505c44b' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '087ed140-8731-0792-70d1-e92e2505c44b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '087ed140-8731-0792-70d1-e92e2505c44b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='087ed140-8731-0792-70d1-e92e2505c44b' order by vacyear; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '087ed140-8731-0792-70d1-e92e2505c44b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='a3ae61bb-a890-70cf-97a5-f3379f446d1e' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -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='a3ae61bb-a890-70cf-97a5-f3379f446d1e' order by startdate,enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='a3ae61bb-a890-70cf-97a5-f3379f446d1e' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'a3ae61bb-a890-70cf-97a5-f3379f446d1e' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'a3ae61bb-a890-70cf-97a5-f3379f446d1e' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'a3ae61bb-a890-70cf-97a5-f3379f446d1e' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'a3ae61bb-a890-70cf-97a5-f3379f446d1e' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' order by startdate,enddate; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' order by vacyear; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='087ed140-8731-0792-70d1-e92e2505c44b' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '087ed140-8731-0792-70d1-e92e2505c44b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='087ed140-8731-0792-70d1-e92e2505c44b' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '087ed140-8731-0792-70d1-e92e2505c44b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '087ed140-8731-0792-70d1-e92e2505c44b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='087ed140-8731-0792-70d1-e92e2505c44b' 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='087ed140-8731-0792-70d1-e92e2505c44b' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '087ed140-8731-0792-70d1-e92e2505c44b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='a3ae61bb-a890-70cf-97a5-f3379f446d1e' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'a3ae61bb-a890-70cf-97a5-f3379f446d1e' - 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='a3ae61bb-a890-70cf-97a5-f3379f446d1e' order by vacyear; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'a3ae61bb-a890-70cf-97a5-f3379f446d1e' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'a3ae61bb-a890-70cf-97a5-f3379f446d1e' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='a3ae61bb-a890-70cf-97a5-f3379f446d1e' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'a3ae61bb-a890-70cf-97a5-f3379f446d1e' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -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='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' order by startdate,enddate; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - 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='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' order by vacyear; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='3ea6073d-3f9c-7106-b30e-aa8502884fb6' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -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='3ea6073d-3f9c-7106-b30e-aa8502884fb6' order by startdate,enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='3ea6073d-3f9c-7106-b30e-aa8502884fb6' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='3ea6073d-3f9c-7106-b30e-aa8502884fb6' order by vacyear; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '3ea6073d-3f9c-7106-b30e-aa8502884fb6' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '3ea6073d-3f9c-7106-b30e-aa8502884fb6' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '3ea6073d-3f9c-7106-b30e-aa8502884fb6' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '3ea6073d-3f9c-7106-b30e-aa8502884fb6' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '3ea6073d-3f9c-7106-b30e-aa8502884fb6' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '3ea6073d-3f9c-7106-b30e-aa8502884fb6' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='087ed140-8731-0792-70d1-e92e2505c44b' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -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='087ed140-8731-0792-70d1-e92e2505c44b' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='087ed140-8731-0792-70d1-e92e2505c44b' order by vacyear; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '087ed140-8731-0792-70d1-e92e2505c44b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='087ed140-8731-0792-70d1-e92e2505c44b' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '087ed140-8731-0792-70d1-e92e2505c44b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '087ed140-8731-0792-70d1-e92e2505c44b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '087ed140-8731-0792-70d1-e92e2505c44b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '087ed140-8731-0792-70d1-e92e2505c44b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: 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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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 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; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select ttr.*, st.* ,stg.groupname,'' || COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' 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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from kraeltgen.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='kraeltgen') ttr -where st.isdeleted is null order by groupname,st.staffnumber,surname,prename; -QUERYARRAY: select id,trackername from kraeltgen.timetrackerconfig order by trackername -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='087ed140-8731-0792-70d1-e92e2505c44b' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -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='087ed140-8731-0792-70d1-e92e2505c44b' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='087ed140-8731-0792-70d1-e92e2505c44b' order by vacyear; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='087ed140-8731-0792-70d1-e92e2505c44b' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '087ed140-8731-0792-70d1-e92e2505c44b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '087ed140-8731-0792-70d1-e92e2505c44b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '087ed140-8731-0792-70d1-e92e2505c44b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '087ed140-8731-0792-70d1-e92e2505c44b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '087ed140-8731-0792-70d1-e92e2505c44b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='a3ae61bb-a890-70cf-97a5-f3379f446d1e' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -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='a3ae61bb-a890-70cf-97a5-f3379f446d1e' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='a3ae61bb-a890-70cf-97a5-f3379f446d1e' order by vacyear; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'a3ae61bb-a890-70cf-97a5-f3379f446d1e' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'a3ae61bb-a890-70cf-97a5-f3379f446d1e' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='a3ae61bb-a890-70cf-97a5-f3379f446d1e' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'a3ae61bb-a890-70cf-97a5-f3379f446d1e' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'a3ae61bb-a890-70cf-97a5-f3379f446d1e' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='087ed140-8731-0792-70d1-e92e2505c44b' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -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='087ed140-8731-0792-70d1-e92e2505c44b' order by startdate,enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '087ed140-8731-0792-70d1-e92e2505c44b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '087ed140-8731-0792-70d1-e92e2505c44b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='087ed140-8731-0792-70d1-e92e2505c44b' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '087ed140-8731-0792-70d1-e92e2505c44b' - 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='087ed140-8731-0792-70d1-e92e2505c44b' order by vacyear; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '087ed140-8731-0792-70d1-e92e2505c44b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '087ed140-8731-0792-70d1-e92e2505c44b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '087ed140-8731-0792-70d1-e92e2505c44b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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 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 id,trackername from kraeltgen.timetrackerconfig order by trackername -QUERYARRAY: select ttr.*, st.* ,stg.groupname,'' || COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' 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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from kraeltgen.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='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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='087ed140-8731-0792-70d1-e92e2505c44b' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -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='087ed140-8731-0792-70d1-e92e2505c44b' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='087ed140-8731-0792-70d1-e92e2505c44b' order by vacyear; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '087ed140-8731-0792-70d1-e92e2505c44b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='087ed140-8731-0792-70d1-e92e2505c44b' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '087ed140-8731-0792-70d1-e92e2505c44b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '087ed140-8731-0792-70d1-e92e2505c44b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '087ed140-8731-0792-70d1-e92e2505c44b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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 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 ttr.*, st.* ,stg.groupname,'' || COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' 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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from kraeltgen.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='kraeltgen') ttr -where st.isdeleted is null order by groupname,st.staffnumber,surname,prename; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='087ed140-8731-0792-70d1-e92e2505c44b' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '087ed140-8731-0792-70d1-e92e2505c44b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='087ed140-8731-0792-70d1-e92e2505c44b' 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='087ed140-8731-0792-70d1-e92e2505c44b' order by startdate,enddate; -se when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='087ed140-8731-0792-70d1-e92e2505c44b' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '087ed140-8731-0792-70d1-e92e2505c44b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '087ed140-8731-0792-70d1-e92e2505c44b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '087ed140-8731-0792-70d1-e92e2505c44b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '087ed140-8731-0792-70d1-e92e2505c44b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '087ed140-8731-0792-70d1-e92e2505c44b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '087ed140-8731-0792-70d1-e92e2505c44b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '087ed140-8731-0792-70d1-e92e2505c44b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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; -ce(st.job,'') || '' 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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from kraeltgen.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='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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='a3ae61bb-a890-70cf-97a5-f3379f446d1e' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -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='a3ae61bb-a890-70cf-97a5-f3379f446d1e' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='a3ae61bb-a890-70cf-97a5-f3379f446d1e' order by vacyear; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='a3ae61bb-a890-70cf-97a5-f3379f446d1e' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'a3ae61bb-a890-70cf-97a5-f3379f446d1e' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'a3ae61bb-a890-70cf-97a5-f3379f446d1e' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='087ed140-8731-0792-70d1-e92e2505c44b' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '087ed140-8731-0792-70d1-e92e2505c44b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -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='087ed140-8731-0792-70d1-e92e2505c44b' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='087ed140-8731-0792-70d1-e92e2505c44b' order by vacyear; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='087ed140-8731-0792-70d1-e92e2505c44b' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '087ed140-8731-0792-70d1-e92e2505c44b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '087ed140-8731-0792-70d1-e92e2505c44b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '087ed140-8731-0792-70d1-e92e2505c44b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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 ttr.*, st.* ,stg.groupname,'' || COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' 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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from kraeltgen.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='kraeltgen') ttr -where st.isdeleted is null order by groupname,st.staffnumber,surname,prename; -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 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='087ed140-8731-0792-70d1-e92e2505c44b' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -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='087ed140-8731-0792-70d1-e92e2505c44b' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='087ed140-8731-0792-70d1-e92e2505c44b' order by vacyear; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='087ed140-8731-0792-70d1-e92e2505c44b' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '087ed140-8731-0792-70d1-e92e2505c44b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '087ed140-8731-0792-70d1-e92e2505c44b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '087ed140-8731-0792-70d1-e92e2505c44b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '087ed140-8731-0792-70d1-e92e2505c44b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' 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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from kraeltgen.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='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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='087ed140-8731-0792-70d1-e92e2505c44b' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -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='087ed140-8731-0792-70d1-e92e2505c44b' order by startdate,enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='087ed140-8731-0792-70d1-e92e2505c44b' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '087ed140-8731-0792-70d1-e92e2505c44b' - 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='087ed140-8731-0792-70d1-e92e2505c44b' order by vacyear; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '087ed140-8731-0792-70d1-e92e2505c44b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '087ed140-8731-0792-70d1-e92e2505c44b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '087ed140-8731-0792-70d1-e92e2505c44b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='afe52b22-342a-204a-f5c0-492ac2b23319' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -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='afe52b22-342a-204a-f5c0-492ac2b23319' order by startdate,enddate; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'afe52b22-342a-204a-f5c0-492ac2b23319' - 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='afe52b22-342a-204a-f5c0-492ac2b23319' order by vacyear; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'afe52b22-342a-204a-f5c0-492ac2b23319' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'afe52b22-342a-204a-f5c0-492ac2b23319' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='afe52b22-342a-204a-f5c0-492ac2b23319' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'afe52b22-342a-204a-f5c0-492ac2b23319' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='e3ed2959-a411-2f14-b40a-27251d8f6d0c' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by vacyear; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -en mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='3ea6073d-3f9c-7106-b30e-aa8502884fb6' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='3ea6073d-3f9c-7106-b30e-aa8502884fb6' 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='3ea6073d-3f9c-7106-b30e-aa8502884fb6' order by startdate,enddate; -cyhours, '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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '3ea6073d-3f9c-7106-b30e-aa8502884fb6' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='3ea6073d-3f9c-7106-b30e-aa8502884fb6' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '3ea6073d-3f9c-7106-b30e-aa8502884fb6' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '3ea6073d-3f9c-7106-b30e-aa8502884fb6' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '3ea6073d-3f9c-7106-b30e-aa8502884fb6' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -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='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' order by vacyear; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039' -QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff - ,to_char(ws.workhours::interval,'HH24:MI') as workhours - ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal - ,to_char(ws.vacillhours,'HH24:MI') as vacancyill - ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra - ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours - ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours - ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours - ,to_char(ws.totalhours,'HH24:MI') as totalhours - ,cd.contractworkdays - ,cd.cmpcontractdays - ,cd.cmpweekhours - ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours - ,ws.periodworkhours - ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff - ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours - ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff - ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours - ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours - ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours - ,case when cd.contractworkdays < cd.cmpcontractdays then - to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI') - else - to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI') - end as maxweekhours - ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else - to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI') - end as defaultweekhours - from ( - SELECT weekstart,weekend,calweek,calyear, id_staff, - sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours, - sum(case when srpd.daydate between date('2022-01-01') and date('2022-06-30') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours, - --sum(case when srpd.daydate between date('2022-01-01') and date('2022-06-30') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause, - sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours, - sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours, - sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours, - sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours, - sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours, - sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours, - sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours, - sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays, - sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' and daydate between date('2021-12-27') and date('2022-07-03') - ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff - ORDER BY weekstart) ws left join ( - select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours, - case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays, - case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays - from ( select id_staff,weekdays ,weekhours, - case when startdate> date('2021-12-27') then startdate else date('2021-12-27') end as staffperiodstart, - case when enddate is null or enddate > date('2022-07-03') then date('2022-07-03') - else enddate end as staffperiodend from kraeltgen.staffcontract where id_staff='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - and startdate < date('2022-07-03') - ) sc - join kraeltgen.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend) - group by date(date_trunc('week',pd.daydate)),pd.id_staff - ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart - left join ( - select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from ( - select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate, - case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours , - case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours - from kraeltgen.staffreportperioddays lpd - left join kraeltgen.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate) - cross join (select * from kraeltgen.worktimes where isdefault=true) wkdef - where id_staff='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' and lpd.daydate between date('2021-12-27') and date('2022-07-03') - order by lpd.daydate ) mh group by id_staff,weekstart - ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart - left join ( - select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from ( - select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from ( -select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from kraeltgen.timetracker -where daydate between date('2022-01-01') and date('2022-06-30') and id_staff ='f90f0cc3-7a37-f6e0-fa25-0d63aee82147') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff - ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment, - vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment, - date(date_trunc('week',pd.daydate)) as weekstart, - to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1, - to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1, - to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2, - to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2, - to_char(pd.timepause::interval, 'HH24:MI') AS timepause, - -- coalesce('
' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '
','') AS dspvacancyhours, - to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours, - to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours, - to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours, - to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours, - to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours, - to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours, - to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours, - to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours, - to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours, - to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours, - to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours, - to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1, - to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1, - to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2, - to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2, - COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata, - COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata, - CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter, - to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours, - to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours, - to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation, - to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours, - max(vd.vacancyname) as vacancyname, - to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime, - interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff, - max(tt.incompletetrack) as incompletetrack - FROM kraeltgen.staffreportperioddays pd - JOIN kraeltgen.staff st ON pd.id_staff = st.id and st.id='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' and st.isdeleted is null - LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto, - yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval, - date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate - left join kraeltgen.worktimes wk on pd.daydate between wk.startdate and wk.enddate - cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from kraeltgen.worktimes where isdefault =true) wkstd - left join kraeltgen.vacancydays vd on pd.daydate=vd.daydate - left join ( - select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime, - sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack -from kraeltgen.timetracker where id_staff='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' and daydate between date('2022-05-30') and date('2022-07-03') group by daydate - ) tt on pd.daydate=tt.daydate - WHERE pd.daydate between date('2022-05-30') and date('2022-07-03') - group by pd.id - ORDER BY pd.id_staff, pd.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039' -QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff - ,to_char(ws.workhours::interval,'HH24:MI') as workhours - ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal - ,to_char(ws.vacillhours,'HH24:MI') as vacancyill - ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra - ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours - ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours - ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours - ,to_char(ws.totalhours,'HH24:MI') as totalhours - ,cd.contractworkdays - ,cd.cmpcontractdays - ,cd.cmpweekhours - ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours - ,ws.periodworkhours - ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff - ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours - ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff - ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours - ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours - ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours - ,case when cd.contractworkdays < cd.cmpcontractdays then - to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI') - else - to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI') - end as maxweekhours - ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else - to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI') - end as defaultweekhours - from ( - SELECT weekstart,weekend,calweek,calyear, id_staff, - sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours, - sum(case when srpd.daydate between date('2022-01-01') and date('2022-06-30') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours, - --sum(case when srpd.daydate between date('2022-01-01') and date('2022-06-30') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause, - sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours, - sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours, - sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours, - sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours, - sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours, - sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours, - sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours, - sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays, - sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' and daydate between date('2021-12-27') and date('2022-07-03') - ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff - ORDER BY weekstart) ws left join ( - select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours, - case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays, - case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays - from ( select id_staff,weekdays ,weekhours, - case when startdate> date('2021-12-27') then startdate else date('2021-12-27') end as staffperiodstart, - case when enddate is null or enddate > date('2022-07-03') then date('2022-07-03') - else enddate end as staffperiodend from kraeltgen.staffcontract where id_staff='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - and startdate < date('2022-07-03') - ) sc - join kraeltgen.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend) - group by date(date_trunc('week',pd.daydate)),pd.id_staff - ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart - left join ( - select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from ( - select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate, - case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours , - case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours - from kraeltgen.staffreportperioddays lpd - left join kraeltgen.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate) - cross join (select * from kraeltgen.worktimes where isdefault=true) wkdef - where id_staff='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' and lpd.daydate between date('2021-12-27') and date('2022-07-03') - order by lpd.daydate ) mh group by id_staff,weekstart - ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart - left join ( - select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from ( - select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from ( -select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from kraeltgen.timetracker -where daydate between date('2022-01-01') and date('2022-06-30') and id_staff ='f90f0cc3-7a37-f6e0-fa25-0d63aee82147') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff - ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment, - vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment, - date(date_trunc('week',pd.daydate)) as weekstart, - to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1, - to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1, - to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2, - to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2, - to_char(pd.timepause::interval, 'HH24:MI') AS timepause, - -- coalesce('
' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '
','') AS dspvacancyhours, - to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours, - to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours, - to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours, - to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours, - to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours, - to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours, - to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours, - to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours, - to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours, - to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours, - to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours, - to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1, - to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1, - to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2, - to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2, - COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata, - COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata, - CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter, - to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours, - to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours, - to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation, - to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours, - max(vd.vacancyname) as vacancyname, - to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime, - interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff, - max(tt.incompletetrack) as incompletetrack - FROM kraeltgen.staffreportperioddays pd - JOIN kraeltgen.staff st ON pd.id_staff = st.id and st.id='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' and st.isdeleted is null - LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto, - yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval, - date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate - left join kraeltgen.worktimes wk on pd.daydate between wk.startdate and wk.enddate - cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from kraeltgen.worktimes where isdefault =true) wkstd - left join kraeltgen.vacancydays vd on pd.daydate=vd.daydate - left join ( - select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime, - sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack -from kraeltgen.timetracker where id_staff='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' and daydate between date('2022-03-28') and date('2022-05-01') group by daydate - ) tt on pd.daydate=tt.daydate - WHERE pd.daydate between date('2022-03-28') and date('2022-05-01') - group by pd.id - ORDER BY pd.id_staff, pd.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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 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 id,trackername from kraeltgen.timetrackerconfig order by trackername -QUERYARRAY: select ttr.*, st.* ,stg.groupname,'' || COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' 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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from kraeltgen.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='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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='73f003c0-4912-7c00-e38a-ce42f36bbbfb' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '73f003c0-4912-7c00-e38a-ce42f36bbbfb' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='73f003c0-4912-7c00-e38a-ce42f36bbbfb' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='73f003c0-4912-7c00-e38a-ce42f36bbbfb' order by vacyear; -riod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '73f003c0-4912-7c00-e38a-ce42f36bbbfb' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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='73f003c0-4912-7c00-e38a-ce42f36bbbfb' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '73f003c0-4912-7c00-e38a-ce42f36bbbfb' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '73f003c0-4912-7c00-e38a-ce42f36bbbfb' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '73f003c0-4912-7c00-e38a-ce42f36bbbfb' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '73f003c0-4912-7c00-e38a-ce42f36bbbfb' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039' -QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff - ,to_char(ws.workhours::interval,'HH24:MI') as workhours - ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal - ,to_char(ws.vacillhours,'HH24:MI') as vacancyill - ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra - ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours - ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours - ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours - ,to_char(ws.totalhours,'HH24:MI') as totalhours - ,cd.contractworkdays - ,cd.cmpcontractdays - ,cd.cmpweekhours - ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours - ,ws.periodworkhours - ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff - ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours - ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff - ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours - ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours - ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours - ,case when cd.contractworkdays < cd.cmpcontractdays then - to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI') - else - to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI') - end as maxweekhours - ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else - to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI') - end as defaultweekhours - from ( - SELECT weekstart,weekend,calweek,calyear, id_staff, - sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours, - sum(case when srpd.daydate between date('2022-01-01') and date('2022-06-30') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours, - --sum(case when srpd.daydate between date('2022-01-01') and date('2022-06-30') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause, - sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours, - sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours, - sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours, - sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours, - sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours, - sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours, - sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours, - sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays, - sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '73f003c0-4912-7c00-e38a-ce42f36bbbfb' and daydate between date('2021-12-27') and date('2022-07-03') - ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff - ORDER BY weekstart) ws left join ( - select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours, - case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays, - case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays - from ( select id_staff,weekdays ,weekhours, - case when startdate> date('2021-12-27') then startdate else date('2021-12-27') end as staffperiodstart, - case when enddate is null or enddate > date('2022-07-03') then date('2022-07-03') - else enddate end as staffperiodend from kraeltgen.staffcontract where id_staff='73f003c0-4912-7c00-e38a-ce42f36bbbfb' - and startdate < date('2022-07-03') - ) sc - join kraeltgen.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend) - group by date(date_trunc('week',pd.daydate)),pd.id_staff - ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart - left join ( - select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from ( - select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate, - case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours , - case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours - from kraeltgen.staffreportperioddays lpd - left join kraeltgen.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate) - cross join (select * from kraeltgen.worktimes where isdefault=true) wkdef - where id_staff='73f003c0-4912-7c00-e38a-ce42f36bbbfb' and lpd.daydate between date('2021-12-27') and date('2022-07-03') - order by lpd.daydate ) mh group by id_staff,weekstart - ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart - left join ( - select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from ( - select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from ( -select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from kraeltgen.timetracker -where daydate between date('2022-01-01') and date('2022-06-30') and id_staff ='73f003c0-4912-7c00-e38a-ce42f36bbbfb') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff - ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment, - vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment, - date(date_trunc('week',pd.daydate)) as weekstart, - to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1, - to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1, - to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2, - to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2, - to_char(pd.timepause::interval, 'HH24:MI') AS timepause, - -- coalesce('
' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '
','') AS dspvacancyhours, - to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours, - to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours, - to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours, - to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours, - to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours, - to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours, - to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours, - to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours, - to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours, - to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours, - to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours, - to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1, - to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1, - to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2, - to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2, - COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata, - COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata, - CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter, - to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours, - to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours, - to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation, - to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours, - max(vd.vacancyname) as vacancyname, - to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime, - interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff, - max(tt.incompletetrack) as incompletetrack - FROM kraeltgen.staffreportperioddays pd - JOIN kraeltgen.staff st ON pd.id_staff = st.id and st.id='73f003c0-4912-7c00-e38a-ce42f36bbbfb' and st.isdeleted is null - LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto, - yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval, - date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate - left join kraeltgen.worktimes wk on pd.daydate between wk.startdate and wk.enddate - cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from kraeltgen.worktimes where isdefault =true) wkstd - left join kraeltgen.vacancydays vd on pd.daydate=vd.daydate - left join ( - select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime, - sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack -from kraeltgen.timetracker where id_staff='73f003c0-4912-7c00-e38a-ce42f36bbbfb' and daydate between date('2021-12-27') and date('2022-02-06') group by daydate - ) tt on pd.daydate=tt.daydate - WHERE pd.daydate between date('2021-12-27') and date('2022-02-06') - group by pd.id - ORDER BY pd.id_staff, pd.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: 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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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 kraeltgen.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 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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_reportperiod = '529236a0-bb8e-c0dd-6dfd-406fe2f59aff' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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_reportperiod = '872690b5-74c8-6eb3-2c9c-2ad47ea57995' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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 kraeltgen.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 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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 kraeltgen.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 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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_reportperiod = '529236a0-bb8e-c0dd-6dfd-406fe2f59aff' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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_reportperiod = '35fda5d9-36ef-528b-4339-286589719039' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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_reportperiod = 'd1fe1b59-0129-bb85-53da-a4f9f69d9b83' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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_reportperiod = 'ec6261df-f5df-d1b9-7ca1-639d79e82bfe' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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_reportperiod = '35fda5d9-36ef-528b-4339-286589719039' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id from kraeltgen.staff where isdeleted is null; -QUERYARRAY: select id from kraeltgen.reportperiod order by startdate,enddate; -QUERYARRAY: select id,startdate,enddate from kraeltgen.reportperiod where -startdate >= date((select min(startdate) from kraeltgen.staffcontract where id_staff='97648c64-05b7-516a-48a2-23d31511451a')) -or date((select min(startdate) from kraeltgen.staffcontract where id_staff='97648c64-05b7-516a-48a2-23d31511451a')) between startdate and enddate order by startdate,enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-01'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-26'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and (daydate > date('2022-07-03') or daydate < date('2021-07-26')) - OR (id_staff='97648c64-05b7-516a-48a2-23d31511451a' AND daydate not between date('2021-07-26') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('a0538335-1f82-8312-8a62-2e42ea74ed20','97648c64-05b7-516a-48a2-23d31511451a') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-01'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-26'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and (daydate > date('2022-07-03') or daydate < date('2021-07-26')) - OR (id_staff='97648c64-05b7-516a-48a2-23d31511451a' AND daydate not between date('2021-07-26') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('ec6261df-f5df-d1b9-7ca1-639d79e82bfe','97648c64-05b7-516a-48a2-23d31511451a') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-01'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-26'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and (daydate > date('2022-07-03') or daydate < date('2021-07-26')) - OR (id_staff='97648c64-05b7-516a-48a2-23d31511451a' AND daydate not between date('2021-07-26') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('d1fe1b59-0129-bb85-53da-a4f9f69d9b83','97648c64-05b7-516a-48a2-23d31511451a') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-01'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-26'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and (daydate > date('2022-07-03') or daydate < date('2021-07-26')) - OR (id_staff='97648c64-05b7-516a-48a2-23d31511451a' AND daydate not between date('2021-07-26') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('35fda5d9-36ef-528b-4339-286589719039','97648c64-05b7-516a-48a2-23d31511451a') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select reportperiodunit,reportperiodlength from public.companies where schemata='kraeltgen' -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' - ) scx where startdate < enddate and id='a0538335-1f82-8312-8a62-2e42ea74ed20' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-08-01'),date('2021-08-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 21 as maxdays,21 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2021-07-01') and date('2021-08-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-08-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-08-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='97648c64-05b7-516a-48a2-23d31511451a' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=21,contracthours='168:00:00' where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select * from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by rp.startdate,rp.enddate) - sper ) prp where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-07-01') and date('2021-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-07-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and sr.daydate between date('2021-07-01') and date(date_trunc('week',date('2021-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days') - --where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2021-07-01') and date('2021-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=3,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2021-08-30'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a0538335-1f82-8312-8a62-2e42ea74ed20') - where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and pd.daydate between date('2021-07-01') and date('2021-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' - ) scx where startdate < enddate and id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-09-01'),date('2021-10-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 45 as maxdays,45 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2021-09-01') and date('2021-10-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-10-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-10-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='97648c64-05b7-516a-48a2-23d31511451a' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=45,contracthours='360:00:00' where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -QUERY: select * from kraeltgen.reportperiod where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by rp.startdate,rp.enddate) - sper ) prp where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='a0538335-1f82-8312-8a62-2e42ea74ed20' and id_staff='97648c64-05b7-516a-48a2-23d31511451a'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,3+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-09-01') and date('2021-10-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,2+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and sr.daydate between date('2021-08-30') and date(date_trunc('week',date('2021-10-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days') - --where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2021-09-01') and date('2021-10-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=12,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2021-10-25'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'ec6261df-f5df-d1b9-7ca1-639d79e82bfe') - where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and pd.daydate between date('2021-09-01') and date('2021-10-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' - ) scx where startdate < enddate and id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-11-01'),date('2021-12-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 43 as maxdays,43 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2021-11-01') and date('2021-12-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-12-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-12-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='97648c64-05b7-516a-48a2-23d31511451a' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=43,contracthours='344:00:00' where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -QUERY: select * from kraeltgen.reportperiod where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by rp.startdate,rp.enddate) - sper ) prp where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='ec6261df-f5df-d1b9-7ca1-639d79e82bfe' and id_staff='97648c64-05b7-516a-48a2-23d31511451a'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,12+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-11-01') and date('2021-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-11-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,3+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and sr.daydate between date('2021-10-25') and date(date_trunc('week',date('2021-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days') - --where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2021-11-01') and date('2021-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=19,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=6,last44date=date('2021-12-27'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd1fe1b59-0129-bb85-53da-a4f9f69d9b83') - where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and pd.daydate between date('2021-11-01') and date('2021-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' - ) scx where startdate < enddate and id='35fda5d9-36ef-528b-4339-286589719039' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2022-01-01'),date('2022-06-30'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 129 as maxdays,129 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2022-01-01') and date('2022-06-30') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2022-06-30') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2022-06-30')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='97648c64-05b7-516a-48a2-23d31511451a' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=129,contracthours='1032:00:00' where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod='35fda5d9-36ef-528b-4339-286589719039'; -QUERY: select * from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by rp.startdate,rp.enddate) - sper ) prp where id='35fda5d9-36ef-528b-4339-286589719039'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='d1fe1b59-0129-bb85-53da-a4f9f69d9b83' and id_staff='97648c64-05b7-516a-48a2-23d31511451a'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,19+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2022-01-01') and date('2022-06-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,6+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and sr.daydate between date('2021-12-27') and date(date_trunc('week',date('2022-06-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days') - --where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2022-01-01') and date('2022-06-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=35,suppvacancysunwork=2,suppvacancy44hours=1,status44hcount=1,last44date=date('2022-05-02'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '35fda5d9-36ef-528b-4339-286589719039') - where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and pd.daydate between date('2022-01-01') and date('2022-06-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -EXEC: insert into kraeltgen.staffvacancyyear (id_staff,vacyear) - select id_staff,to_char(daydate,'YYYY')::int4 as vyear from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by id_staff,vyear order by id_staff,vyear - on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-01'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-26'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and (daydate > date('2022-07-03') or daydate < date('2021-07-26')) - OR (id_staff='97648c64-05b7-516a-48a2-23d31511451a' AND daydate not between date('2021-07-26') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by rp.startdate,rp.enddate) - sper ) prp where id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-01-01'))) and date(date_trunc('week',date('2020-02-29')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-01-01'))) and date(date_trunc('week',date('2020-02-29')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-01-01') and date('2020-02-29') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and sr.daydate between date('2020-01-01') and date(date_trunc('week',date('2020-02-29')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-01-01'))) and date(date_trunc('week',date('2020-02-29')) + interval '6 days') - --where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2020-01-01') and date('2020-02-29') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '529236a0-bb8e-c0dd-6dfd-406fe2f59aff') - where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and pd.daydate between date('2020-01-01') and date('2020-02-29') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='872690b5-74c8-6eb3-2c9c-2ad47ea57995'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-01'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-26'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and (daydate > date('2022-07-03') or daydate < date('2021-07-26')) - OR (id_staff='97648c64-05b7-516a-48a2-23d31511451a' AND daydate not between date('2021-07-26') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='872690b5-74c8-6eb3-2c9c-2ad47ea57995'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by rp.startdate,rp.enddate) - sper ) prp where id='872690b5-74c8-6eb3-2c9c-2ad47ea57995'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-03-01'))) and date(date_trunc('week',date('2020-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-03-01'))) and date(date_trunc('week',date('2020-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-03-01') and date('2020-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-03-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and sr.daydate between date('2020-03-01') and date(date_trunc('week',date('2020-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-03-01'))) and date(date_trunc('week',date('2020-04-30')) + interval '6 days') - --where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2020-03-01') and date('2020-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '872690b5-74c8-6eb3-2c9c-2ad47ea57995') - where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and pd.daydate between date('2020-03-01') and date('2020-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='c70d0d68-b69f-2b02-cec3-d82b47eca9b6'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-01'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-26'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and (daydate > date('2022-07-03') or daydate < date('2021-07-26')) - OR (id_staff='97648c64-05b7-516a-48a2-23d31511451a' AND daydate not between date('2021-07-26') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='c70d0d68-b69f-2b02-cec3-d82b47eca9b6'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by rp.startdate,rp.enddate) - sper ) prp where id='c70d0d68-b69f-2b02-cec3-d82b47eca9b6'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-05-01'))) and date(date_trunc('week',date('2020-06-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-05-01'))) and date(date_trunc('week',date('2020-06-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-05-01') and date('2020-06-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and sr.daydate between date('2020-05-01') and date(date_trunc('week',date('2020-06-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-05-01'))) and date(date_trunc('week',date('2020-06-30')) + interval '6 days') - --where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2020-05-01') and date('2020-06-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'c70d0d68-b69f-2b02-cec3-d82b47eca9b6') - where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and pd.daydate between date('2020-05-01') and date('2020-06-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-01'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-26'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and (daydate > date('2022-07-03') or daydate < date('2021-07-26')) - OR (id_staff='97648c64-05b7-516a-48a2-23d31511451a' AND daydate not between date('2021-07-26') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by rp.startdate,rp.enddate) - sper ) prp where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-07-01') and date('2020-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-07-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and sr.daydate between date('2020-07-01') and date(date_trunc('week',date('2020-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days') - --where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2020-07-01') and date('2020-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'f9ed771d-6236-f6f3-caa7-e678a49023d0') - where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and pd.daydate between date('2020-07-01') and date('2020-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-01'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-26'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and (daydate > date('2022-07-03') or daydate < date('2021-07-26')) - OR (id_staff='97648c64-05b7-516a-48a2-23d31511451a' AND daydate not between date('2021-07-26') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by rp.startdate,rp.enddate) - sper ) prp where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-09-01') and date('2020-10-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and sr.daydate between date('2020-09-01') and date(date_trunc('week',date('2020-10-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days') - --where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2020-09-01') and date('2020-10-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '1f489513-7b98-efb4-d16d-f3baeceb846a') - where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and pd.daydate between date('2020-09-01') and date('2020-10-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-01'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-26'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and (daydate > date('2022-07-03') or daydate < date('2021-07-26')) - OR (id_staff='97648c64-05b7-516a-48a2-23d31511451a' AND daydate not between date('2021-07-26') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by rp.startdate,rp.enddate) - sper ) prp where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-11-01') and date('2020-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-11-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and sr.daydate between date('2020-11-01') and date(date_trunc('week',date('2020-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days') - --where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2020-11-01') and date('2020-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '83f75caf-b28e-5c31-cd74-d7a7bd23e960') - where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and pd.daydate between date('2020-11-01') and date('2020-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-01'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-26'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and (daydate > date('2022-07-03') or daydate < date('2021-07-26')) - OR (id_staff='97648c64-05b7-516a-48a2-23d31511451a' AND daydate not between date('2021-07-26') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by rp.startdate,rp.enddate) - sper ) prp where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-01-01') and date('2021-02-28') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and sr.daydate between date('2021-01-01') and date(date_trunc('week',date('2021-02-28')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days') - --where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2021-01-01') and date('2021-02-28') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'da4487e9-aaf6-ee29-0718-0e6b61ab9ebc') - where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and pd.daydate between date('2021-01-01') and date('2021-02-28') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='d85f8825-82dc-ff12-24c3-94e2967d22c0'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-01'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-26'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and (daydate > date('2022-07-03') or daydate < date('2021-07-26')) - OR (id_staff='97648c64-05b7-516a-48a2-23d31511451a' AND daydate not between date('2021-07-26') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='d85f8825-82dc-ff12-24c3-94e2967d22c0'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by rp.startdate,rp.enddate) - sper ) prp where id='d85f8825-82dc-ff12-24c3-94e2967d22c0'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-03-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-03-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-03-01') and date('2021-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-03-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and sr.daydate between date('2021-03-01') and date(date_trunc('week',date('2021-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-03-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days') - --where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2021-03-01') and date('2021-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd85f8825-82dc-ff12-24c3-94e2967d22c0') - where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and pd.daydate between date('2021-03-01') and date('2021-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-01'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-26'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and (daydate > date('2022-07-03') or daydate < date('2021-07-26')) - OR (id_staff='97648c64-05b7-516a-48a2-23d31511451a' AND daydate not between date('2021-07-26') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by rp.startdate,rp.enddate) - sper ) prp where id='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-06-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-06-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-05-01') and date('2021-06-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and sr.daydate between date('2021-05-01') and date(date_trunc('week',date('2021-06-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-06-30')) + interval '6 days') - --where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2021-05-01') and date('2021-06-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1') - where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and pd.daydate between date('2021-05-01') and date('2021-06-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-01'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-26'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and (daydate > date('2022-07-03') or daydate < date('2021-07-26')) - OR (id_staff='97648c64-05b7-516a-48a2-23d31511451a' AND daydate not between date('2021-07-26') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by rp.startdate,rp.enddate) - sper ) prp where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-07-01') and date('2021-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-07-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and sr.daydate between date('2021-07-01') and date(date_trunc('week',date('2021-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days') - --where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2021-07-01') and date('2021-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=3,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2021-08-30'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a0538335-1f82-8312-8a62-2e42ea74ed20') - where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and pd.daydate between date('2021-07-01') and date('2021-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-01'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-26'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and (daydate > date('2022-07-03') or daydate < date('2021-07-26')) - OR (id_staff='97648c64-05b7-516a-48a2-23d31511451a' AND daydate not between date('2021-07-26') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by rp.startdate,rp.enddate) - sper ) prp where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='a0538335-1f82-8312-8a62-2e42ea74ed20' and id_staff='97648c64-05b7-516a-48a2-23d31511451a'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,3+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-09-01') and date('2021-10-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,2+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and sr.daydate between date('2021-08-30') and date(date_trunc('week',date('2021-10-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days') - --where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2021-09-01') and date('2021-10-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=12,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2021-10-25'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'ec6261df-f5df-d1b9-7ca1-639d79e82bfe') - where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and pd.daydate between date('2021-09-01') and date('2021-10-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-01'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-26'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and (daydate > date('2022-07-03') or daydate < date('2021-07-26')) - OR (id_staff='97648c64-05b7-516a-48a2-23d31511451a' AND daydate not between date('2021-07-26') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by rp.startdate,rp.enddate) - sper ) prp where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='ec6261df-f5df-d1b9-7ca1-639d79e82bfe' and id_staff='97648c64-05b7-516a-48a2-23d31511451a'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,12+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-11-01') and date('2021-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-11-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,3+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and sr.daydate between date('2021-10-25') and date(date_trunc('week',date('2021-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days') - --where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2021-11-01') and date('2021-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=19,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=6,last44date=date('2021-12-27'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd1fe1b59-0129-bb85-53da-a4f9f69d9b83') - where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and pd.daydate between date('2021-11-01') and date('2021-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-01'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-26'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and (daydate > date('2022-07-03') or daydate < date('2021-07-26')) - OR (id_staff='97648c64-05b7-516a-48a2-23d31511451a' AND daydate not between date('2021-07-26') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by rp.startdate,rp.enddate) - sper ) prp where id='35fda5d9-36ef-528b-4339-286589719039'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='d1fe1b59-0129-bb85-53da-a4f9f69d9b83' and id_staff='97648c64-05b7-516a-48a2-23d31511451a'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,19+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2022-01-01') and date('2022-06-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,6+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and sr.daydate between date('2021-12-27') and date(date_trunc('week',date('2022-06-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days') - --where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2022-01-01') and date('2022-06-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=35,suppvacancysunwork=2,suppvacancy44hours=1,status44hcount=1,last44date=date('2022-05-02'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '35fda5d9-36ef-528b-4339-286589719039') - where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and pd.daydate between date('2022-01-01') and date('2022-06-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id from kraeltgen.reportperiod order by startdate,enddate; -QUERYARRAY: select id,startdate,enddate from kraeltgen.reportperiod where -startdate >= date((select min(startdate) from kraeltgen.staffcontract where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373')) -or date((select min(startdate) from kraeltgen.staffcontract where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373')) between startdate and enddate order by startdate,enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('f9ed771d-6236-f6f3-caa7-e678a49023d0','d20e29fd-921a-9396-f0cb-2262f9435373') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('1f489513-7b98-efb4-d16d-f3baeceb846a','d20e29fd-921a-9396-f0cb-2262f9435373') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('83f75caf-b28e-5c31-cd74-d7a7bd23e960','d20e29fd-921a-9396-f0cb-2262f9435373') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('da4487e9-aaf6-ee29-0718-0e6b61ab9ebc','d20e29fd-921a-9396-f0cb-2262f9435373') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='d85f8825-82dc-ff12-24c3-94e2967d22c0'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('d85f8825-82dc-ff12-24c3-94e2967d22c0','d20e29fd-921a-9396-f0cb-2262f9435373') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1','d20e29fd-921a-9396-f0cb-2262f9435373') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('a0538335-1f82-8312-8a62-2e42ea74ed20','d20e29fd-921a-9396-f0cb-2262f9435373') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('ec6261df-f5df-d1b9-7ca1-639d79e82bfe','d20e29fd-921a-9396-f0cb-2262f9435373') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('d1fe1b59-0129-bb85-53da-a4f9f69d9b83','d20e29fd-921a-9396-f0cb-2262f9435373') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('35fda5d9-36ef-528b-4339-286589719039','d20e29fd-921a-9396-f0cb-2262f9435373') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select reportperiodunit,reportperiodlength from public.companies where schemata='kraeltgen' -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' - ) scx where startdate < enddate and id='f9ed771d-6236-f6f3-caa7-e678a49023d0' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2020-08-01'),date('2020-08-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 22 as maxdays,22 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2020-07-01') and date('2020-08-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2020-08-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2020-08-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=22,contracthours='176:00:00' where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -QUERY: select * from kraeltgen.reportperiod where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by rp.startdate,rp.enddate) - sper ) prp where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-07-01') and date('2020-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-07-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and sr.daydate between date('2020-07-01') and date(date_trunc('week',date('2020-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days') - --where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2020-07-01') and date('2020-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'f9ed771d-6236-f6f3-caa7-e678a49023d0') - where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and pd.daydate between date('2020-07-01') and date('2020-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'd20e29fd-921a-9396-f0cb-2262f9435373' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' - ) scx where startdate < enddate and id='1f489513-7b98-efb4-d16d-f3baeceb846a' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2020-09-01'),date('2020-10-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 44 as maxdays,44 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2020-09-01') and date('2020-10-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2020-10-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2020-10-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=44,contracthours='352:00:00' where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod='1f489513-7b98-efb4-d16d-f3baeceb846a'; -QUERY: select * from kraeltgen.reportperiod where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by rp.startdate,rp.enddate) - sper ) prp where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='f9ed771d-6236-f6f3-caa7-e678a49023d0' and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-09-01') and date('2020-10-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and sr.daydate between date('2020-09-01') and date(date_trunc('week',date('2020-10-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days') - --where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2020-09-01') and date('2020-10-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '1f489513-7b98-efb4-d16d-f3baeceb846a') - where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and pd.daydate between date('2020-09-01') and date('2020-10-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'd20e29fd-921a-9396-f0cb-2262f9435373' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' - ) scx where startdate < enddate and id='83f75caf-b28e-5c31-cd74-d7a7bd23e960' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2020-11-01'),date('2020-12-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 43 as maxdays,43 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2020-11-01') and date('2020-12-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2020-12-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2020-12-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=43,contracthours='344:00:00' where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -QUERY: select * from kraeltgen.reportperiod where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by rp.startdate,rp.enddate) - sper ) prp where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='1f489513-7b98-efb4-d16d-f3baeceb846a' and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-11-01') and date('2020-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-11-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and sr.daydate between date('2020-11-01') and date(date_trunc('week',date('2020-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days') - --where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2020-11-01') and date('2020-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '83f75caf-b28e-5c31-cd74-d7a7bd23e960') - where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and pd.daydate between date('2020-11-01') and date('2020-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'd20e29fd-921a-9396-f0cb-2262f9435373' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' - ) scx where startdate < enddate and id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-01-01'),date('2021-01-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 23 as maxdays,23 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2021-01-01') and date('2021-02-28') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-02-28') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-02-28')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=23,contracthours='184:00:00' where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -QUERY: select * from kraeltgen.reportperiod where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by rp.startdate,rp.enddate) - sper ) prp where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='83f75caf-b28e-5c31-cd74-d7a7bd23e960' and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-01-01') and date('2021-02-28') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and sr.daydate between date('2021-01-01') and date(date_trunc('week',date('2021-02-28')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days') - --where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2021-01-01') and date('2021-02-28') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'da4487e9-aaf6-ee29-0718-0e6b61ab9ebc') - where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and pd.daydate between date('2021-01-01') and date('2021-02-28') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'd20e29fd-921a-9396-f0cb-2262f9435373' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' - ) scx where startdate < enddate and id='d85f8825-82dc-ff12-24c3-94e2967d22c0' order by startdate,enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' - ) scx where startdate < enddate and id='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1' order by startdate,enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' - ) scx where startdate < enddate and id='a0538335-1f82-8312-8a62-2e42ea74ed20' order by startdate,enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' - ) scx where startdate < enddate and id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe' order by startdate,enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' - ) scx where startdate < enddate and id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83' order by startdate,enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' - ) scx where startdate < enddate and id='35fda5d9-36ef-528b-4339-286589719039' order by startdate,enddate; -EXEC: insert into kraeltgen.staffvacancyyear (id_staff,vacyear) - select id_staff,to_char(daydate,'YYYY')::int4 as vyear from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by id_staff,vyear order by id_staff,vyear - on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by rp.startdate,rp.enddate) - sper ) prp where id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-01-01'))) and date(date_trunc('week',date('2020-02-29')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-01-01'))) and date(date_trunc('week',date('2020-02-29')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-01-01') and date('2020-02-29') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and sr.daydate between date('2020-01-01') and date(date_trunc('week',date('2020-02-29')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-01-01'))) and date(date_trunc('week',date('2020-02-29')) + interval '6 days') - --where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2020-01-01') and date('2020-02-29') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '529236a0-bb8e-c0dd-6dfd-406fe2f59aff') - where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and pd.daydate between date('2020-01-01') and date('2020-02-29') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'd20e29fd-921a-9396-f0cb-2262f9435373' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='872690b5-74c8-6eb3-2c9c-2ad47ea57995'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='872690b5-74c8-6eb3-2c9c-2ad47ea57995'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by rp.startdate,rp.enddate) - sper ) prp where id='872690b5-74c8-6eb3-2c9c-2ad47ea57995'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-03-01'))) and date(date_trunc('week',date('2020-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-03-01'))) and date(date_trunc('week',date('2020-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-03-01') and date('2020-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-03-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and sr.daydate between date('2020-03-01') and date(date_trunc('week',date('2020-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-03-01'))) and date(date_trunc('week',date('2020-04-30')) + interval '6 days') - --where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2020-03-01') and date('2020-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '872690b5-74c8-6eb3-2c9c-2ad47ea57995') - where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and pd.daydate between date('2020-03-01') and date('2020-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'd20e29fd-921a-9396-f0cb-2262f9435373' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='c70d0d68-b69f-2b02-cec3-d82b47eca9b6'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='c70d0d68-b69f-2b02-cec3-d82b47eca9b6'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by rp.startdate,rp.enddate) - sper ) prp where id='c70d0d68-b69f-2b02-cec3-d82b47eca9b6'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-05-01'))) and date(date_trunc('week',date('2020-06-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-05-01'))) and date(date_trunc('week',date('2020-06-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-05-01') and date('2020-06-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and sr.daydate between date('2020-05-01') and date(date_trunc('week',date('2020-06-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-05-01'))) and date(date_trunc('week',date('2020-06-30')) + interval '6 days') - --where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2020-05-01') and date('2020-06-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'c70d0d68-b69f-2b02-cec3-d82b47eca9b6') - where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and pd.daydate between date('2020-05-01') and date('2020-06-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'd20e29fd-921a-9396-f0cb-2262f9435373' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by rp.startdate,rp.enddate) - sper ) prp where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-07-01') and date('2020-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-07-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and sr.daydate between date('2020-07-01') and date(date_trunc('week',date('2020-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days') - --where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2020-07-01') and date('2020-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'f9ed771d-6236-f6f3-caa7-e678a49023d0') - where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and pd.daydate between date('2020-07-01') and date('2020-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'd20e29fd-921a-9396-f0cb-2262f9435373' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by rp.startdate,rp.enddate) - sper ) prp where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='f9ed771d-6236-f6f3-caa7-e678a49023d0' and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-09-01') and date('2020-10-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and sr.daydate between date('2020-09-01') and date(date_trunc('week',date('2020-10-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days') - --where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2020-09-01') and date('2020-10-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '1f489513-7b98-efb4-d16d-f3baeceb846a') - where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and pd.daydate between date('2020-09-01') and date('2020-10-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'd20e29fd-921a-9396-f0cb-2262f9435373' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by rp.startdate,rp.enddate) - sper ) prp where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='1f489513-7b98-efb4-d16d-f3baeceb846a' and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-11-01') and date('2020-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-11-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and sr.daydate between date('2020-11-01') and date(date_trunc('week',date('2020-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days') - --where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2020-11-01') and date('2020-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '83f75caf-b28e-5c31-cd74-d7a7bd23e960') - where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and pd.daydate between date('2020-11-01') and date('2020-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'd20e29fd-921a-9396-f0cb-2262f9435373' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by rp.startdate,rp.enddate) - sper ) prp where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='83f75caf-b28e-5c31-cd74-d7a7bd23e960' and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-01-01') and date('2021-02-28') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and sr.daydate between date('2021-01-01') and date(date_trunc('week',date('2021-02-28')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days') - --where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2021-01-01') and date('2021-02-28') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'da4487e9-aaf6-ee29-0718-0e6b61ab9ebc') - where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and pd.daydate between date('2021-01-01') and date('2021-02-28') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'd20e29fd-921a-9396-f0cb-2262f9435373' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='d85f8825-82dc-ff12-24c3-94e2967d22c0'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='d85f8825-82dc-ff12-24c3-94e2967d22c0'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by rp.startdate,rp.enddate) - sper ) prp where id='d85f8825-82dc-ff12-24c3-94e2967d22c0'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-03-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-03-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-03-01') and date('2021-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-03-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and sr.daydate between date('2021-03-01') and date(date_trunc('week',date('2021-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-03-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days') - --where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2021-03-01') and date('2021-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd85f8825-82dc-ff12-24c3-94e2967d22c0') - where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and pd.daydate between date('2021-03-01') and date('2021-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'd20e29fd-921a-9396-f0cb-2262f9435373' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by rp.startdate,rp.enddate) - sper ) prp where id='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-06-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-06-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-05-01') and date('2021-06-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and sr.daydate between date('2021-05-01') and date(date_trunc('week',date('2021-06-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-06-30')) + interval '6 days') - --where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2021-05-01') and date('2021-06-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1') - where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and pd.daydate between date('2021-05-01') and date('2021-06-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'd20e29fd-921a-9396-f0cb-2262f9435373' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by rp.startdate,rp.enddate) - sper ) prp where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-07-01') and date('2021-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-07-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and sr.daydate between date('2021-07-01') and date(date_trunc('week',date('2021-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days') - --where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2021-07-01') and date('2021-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a0538335-1f82-8312-8a62-2e42ea74ed20') - where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and pd.daydate between date('2021-07-01') and date('2021-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'd20e29fd-921a-9396-f0cb-2262f9435373' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by rp.startdate,rp.enddate) - sper ) prp where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-09-01') and date('2021-10-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and sr.daydate between date('2021-09-01') and date(date_trunc('week',date('2021-10-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days') - --where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2021-09-01') and date('2021-10-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'ec6261df-f5df-d1b9-7ca1-639d79e82bfe') - where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and pd.daydate between date('2021-09-01') and date('2021-10-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'd20e29fd-921a-9396-f0cb-2262f9435373' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by rp.startdate,rp.enddate) - sper ) prp where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-11-01') and date('2021-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-11-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and sr.daydate between date('2021-11-01') and date(date_trunc('week',date('2021-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days') - --where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2021-11-01') and date('2021-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd1fe1b59-0129-bb85-53da-a4f9f69d9b83') - where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and pd.daydate between date('2021-11-01') and date('2021-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'd20e29fd-921a-9396-f0cb-2262f9435373' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by rp.startdate,rp.enddate) - sper ) prp where id='35fda5d9-36ef-528b-4339-286589719039'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2022-01-01') and date('2022-06-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and sr.daydate between date('2022-01-01') and date(date_trunc('week',date('2022-06-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days') - --where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2022-01-01') and date('2022-06-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '35fda5d9-36ef-528b-4339-286589719039') - where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and pd.daydate between date('2022-01-01') and date('2022-06-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'd20e29fd-921a-9396-f0cb-2262f9435373' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id from kraeltgen.reportperiod order by startdate,enddate; -QUERYARRAY: select id,startdate,enddate from kraeltgen.reportperiod where -startdate >= date((select min(startdate) from kraeltgen.staffcontract where id_staff='92ff737d-651b-8471-8f34-0587a39171db')) -or date((select min(startdate) from kraeltgen.staffcontract where id_staff='92ff737d-651b-8471-8f34-0587a39171db')) between startdate and enddate order by startdate,enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-07-14'))) as firstday , date(date_trunc('week',date('2021-08-22')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-12'::timestamp,'2021-07-25'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/2 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '10:00:00' as wdcontracthours -FROM generate_series( '2021-08-13'::timestamp,'2021-08-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '10:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/3 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '06:40:12' as wdcontracthours -FROM generate_series( '2021-08-20'::timestamp,'2021-08-22'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '06:40:12'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and (daydate > date('2021-08-22') or daydate < date('2021-07-12')) - OR (id_staff='92ff737d-651b-8471-8f34-0587a39171db' AND daydate not between date('2021-07-12') and date('2021-07-25') AND daydate not between date('2021-08-13') and date('2021-08-14') AND daydate not between date('2021-08-20') and date('2021-08-22')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('a0538335-1f82-8312-8a62-2e42ea74ed20','92ff737d-651b-8471-8f34-0587a39171db') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-07-14'))) as firstday , date(date_trunc('week',date('2021-08-22')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-12'::timestamp,'2021-07-25'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/2 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '10:00:00' as wdcontracthours -FROM generate_series( '2021-08-13'::timestamp,'2021-08-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '10:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/3 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '06:40:12' as wdcontracthours -FROM generate_series( '2021-08-20'::timestamp,'2021-08-22'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '06:40:12'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and (daydate > date('2021-08-22') or daydate < date('2021-07-12')) - OR (id_staff='92ff737d-651b-8471-8f34-0587a39171db' AND daydate not between date('2021-07-12') and date('2021-07-25') AND daydate not between date('2021-08-13') and date('2021-08-14') AND daydate not between date('2021-08-20') and date('2021-08-22')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('ec6261df-f5df-d1b9-7ca1-639d79e82bfe','92ff737d-651b-8471-8f34-0587a39171db') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-07-14'))) as firstday , date(date_trunc('week',date('2021-08-22')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-12'::timestamp,'2021-07-25'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/2 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '10:00:00' as wdcontracthours -FROM generate_series( '2021-08-13'::timestamp,'2021-08-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '10:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/3 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '06:40:12' as wdcontracthours -FROM generate_series( '2021-08-20'::timestamp,'2021-08-22'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '06:40:12'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and (daydate > date('2021-08-22') or daydate < date('2021-07-12')) - OR (id_staff='92ff737d-651b-8471-8f34-0587a39171db' AND daydate not between date('2021-07-12') and date('2021-07-25') AND daydate not between date('2021-08-13') and date('2021-08-14') AND daydate not between date('2021-08-20') and date('2021-08-22')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('d1fe1b59-0129-bb85-53da-a4f9f69d9b83','92ff737d-651b-8471-8f34-0587a39171db') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-07-14'))) as firstday , date(date_trunc('week',date('2021-08-22')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-12'::timestamp,'2021-07-25'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/2 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '10:00:00' as wdcontracthours -FROM generate_series( '2021-08-13'::timestamp,'2021-08-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '10:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/3 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '06:40:12' as wdcontracthours -FROM generate_series( '2021-08-20'::timestamp,'2021-08-22'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '06:40:12'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and (daydate > date('2021-08-22') or daydate < date('2021-07-12')) - OR (id_staff='92ff737d-651b-8471-8f34-0587a39171db' AND daydate not between date('2021-07-12') and date('2021-07-25') AND daydate not between date('2021-08-13') and date('2021-08-14') AND daydate not between date('2021-08-20') and date('2021-08-22')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('35fda5d9-36ef-528b-4339-286589719039','92ff737d-651b-8471-8f34-0587a39171db') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select reportperiodunit,reportperiodlength from public.companies where schemata='kraeltgen' -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' - ) scx where startdate < enddate and id='a0538335-1f82-8312-8a62-2e42ea74ed20' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-07-14'),date('2021-07-25'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 10 as maxdays,10 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2021-07-01') and date('2021-08-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-08-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-08-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='92ff737d-651b-8471-8f34-0587a39171db' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=30,contracthours='246:42:00' where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select * from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by rp.startdate,rp.enddate) - sper ) prp where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-07-01') and date('2021-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-07-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and sr.daydate between date('2021-07-01') and date(date_trunc('week',date('2021-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days') - --where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2021-07-01') and date('2021-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=3,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-08-23'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a0538335-1f82-8312-8a62-2e42ea74ed20') - where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and pd.daydate between date('2021-07-01') and date('2021-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '92ff737d-651b-8471-8f34-0587a39171db' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (3,4,5,6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-08-13'),date('2021-08-14'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 0 as maxdays,0 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2021-07-01') and date('2021-08-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-08-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-08-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='92ff737d-651b-8471-8f34-0587a39171db' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=0,contracthours='00:00:00' where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select * from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by rp.startdate,rp.enddate) - sper ) prp where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-07-01') and date('2021-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-07-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and sr.daydate between date('2021-07-01') and date(date_trunc('week',date('2021-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days') - --where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2021-07-01') and date('2021-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=3,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-08-23'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a0538335-1f82-8312-8a62-2e42ea74ed20') - where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and pd.daydate between date('2021-07-01') and date('2021-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '92ff737d-651b-8471-8f34-0587a39171db' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (4,5,6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-08-20'),date('2021-08-22'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 0 as maxdays,0 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2021-07-01') and date('2021-08-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-08-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-08-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='92ff737d-651b-8471-8f34-0587a39171db' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=0,contracthours='00:00:00' where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select * from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by rp.startdate,rp.enddate) - sper ) prp where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-07-01') and date('2021-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-07-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and sr.daydate between date('2021-07-01') and date(date_trunc('week',date('2021-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days') - --where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2021-07-01') and date('2021-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=3,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-08-23'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a0538335-1f82-8312-8a62-2e42ea74ed20') - where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and pd.daydate between date('2021-07-01') and date('2021-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '92ff737d-651b-8471-8f34-0587a39171db' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' - ) scx where startdate < enddate and id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe' order by startdate,enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' - ) scx where startdate < enddate and id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83' order by startdate,enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' - ) scx where startdate < enddate and id='35fda5d9-36ef-528b-4339-286589719039' order by startdate,enddate; -EXEC: insert into kraeltgen.staffvacancyyear (id_staff,vacyear) - select id_staff,to_char(daydate,'YYYY')::int4 as vyear from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by id_staff,vyear order by id_staff,vyear - on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-07-14'))) as firstday , date(date_trunc('week',date('2021-08-22')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-12'::timestamp,'2021-07-25'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/2 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '10:00:00' as wdcontracthours -FROM generate_series( '2021-08-13'::timestamp,'2021-08-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '10:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/3 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '06:40:12' as wdcontracthours -FROM generate_series( '2021-08-20'::timestamp,'2021-08-22'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '06:40:12'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and (daydate > date('2021-08-22') or daydate < date('2021-07-12')) - OR (id_staff='92ff737d-651b-8471-8f34-0587a39171db' AND daydate not between date('2021-07-12') and date('2021-07-25') AND daydate not between date('2021-08-13') and date('2021-08-14') AND daydate not between date('2021-08-20') and date('2021-08-22')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by rp.startdate,rp.enddate) - sper ) prp where id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-01-01'))) and date(date_trunc('week',date('2020-02-29')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-01-01'))) and date(date_trunc('week',date('2020-02-29')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-01-01') and date('2020-02-29') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and sr.daydate between date('2020-01-01') and date(date_trunc('week',date('2020-02-29')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-01-01'))) and date(date_trunc('week',date('2020-02-29')) + interval '6 days') - --where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2020-01-01') and date('2020-02-29') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '529236a0-bb8e-c0dd-6dfd-406fe2f59aff') - where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and pd.daydate between date('2020-01-01') and date('2020-02-29') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '92ff737d-651b-8471-8f34-0587a39171db' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='872690b5-74c8-6eb3-2c9c-2ad47ea57995'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-07-14'))) as firstday , date(date_trunc('week',date('2021-08-22')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-12'::timestamp,'2021-07-25'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/2 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '10:00:00' as wdcontracthours -FROM generate_series( '2021-08-13'::timestamp,'2021-08-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '10:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/3 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '06:40:12' as wdcontracthours -FROM generate_series( '2021-08-20'::timestamp,'2021-08-22'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '06:40:12'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and (daydate > date('2021-08-22') or daydate < date('2021-07-12')) - OR (id_staff='92ff737d-651b-8471-8f34-0587a39171db' AND daydate not between date('2021-07-12') and date('2021-07-25') AND daydate not between date('2021-08-13') and date('2021-08-14') AND daydate not between date('2021-08-20') and date('2021-08-22')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='872690b5-74c8-6eb3-2c9c-2ad47ea57995'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by rp.startdate,rp.enddate) - sper ) prp where id='872690b5-74c8-6eb3-2c9c-2ad47ea57995'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-03-01'))) and date(date_trunc('week',date('2020-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-03-01'))) and date(date_trunc('week',date('2020-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-03-01') and date('2020-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-03-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and sr.daydate between date('2020-03-01') and date(date_trunc('week',date('2020-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-03-01'))) and date(date_trunc('week',date('2020-04-30')) + interval '6 days') - --where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2020-03-01') and date('2020-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '872690b5-74c8-6eb3-2c9c-2ad47ea57995') - where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and pd.daydate between date('2020-03-01') and date('2020-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '92ff737d-651b-8471-8f34-0587a39171db' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='c70d0d68-b69f-2b02-cec3-d82b47eca9b6'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-07-14'))) as firstday , date(date_trunc('week',date('2021-08-22')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-12'::timestamp,'2021-07-25'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/2 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '10:00:00' as wdcontracthours -FROM generate_series( '2021-08-13'::timestamp,'2021-08-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '10:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/3 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '06:40:12' as wdcontracthours -FROM generate_series( '2021-08-20'::timestamp,'2021-08-22'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '06:40:12'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and (daydate > date('2021-08-22') or daydate < date('2021-07-12')) - OR (id_staff='92ff737d-651b-8471-8f34-0587a39171db' AND daydate not between date('2021-07-12') and date('2021-07-25') AND daydate not between date('2021-08-13') and date('2021-08-14') AND daydate not between date('2021-08-20') and date('2021-08-22')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='c70d0d68-b69f-2b02-cec3-d82b47eca9b6'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by rp.startdate,rp.enddate) - sper ) prp where id='c70d0d68-b69f-2b02-cec3-d82b47eca9b6'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-05-01'))) and date(date_trunc('week',date('2020-06-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-05-01'))) and date(date_trunc('week',date('2020-06-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-05-01') and date('2020-06-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and sr.daydate between date('2020-05-01') and date(date_trunc('week',date('2020-06-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-05-01'))) and date(date_trunc('week',date('2020-06-30')) + interval '6 days') - --where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2020-05-01') and date('2020-06-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'c70d0d68-b69f-2b02-cec3-d82b47eca9b6') - where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and pd.daydate between date('2020-05-01') and date('2020-06-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '92ff737d-651b-8471-8f34-0587a39171db' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-07-14'))) as firstday , date(date_trunc('week',date('2021-08-22')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-12'::timestamp,'2021-07-25'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/2 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '10:00:00' as wdcontracthours -FROM generate_series( '2021-08-13'::timestamp,'2021-08-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '10:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/3 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '06:40:12' as wdcontracthours -FROM generate_series( '2021-08-20'::timestamp,'2021-08-22'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '06:40:12'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and (daydate > date('2021-08-22') or daydate < date('2021-07-12')) - OR (id_staff='92ff737d-651b-8471-8f34-0587a39171db' AND daydate not between date('2021-07-12') and date('2021-07-25') AND daydate not between date('2021-08-13') and date('2021-08-14') AND daydate not between date('2021-08-20') and date('2021-08-22')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by rp.startdate,rp.enddate) - sper ) prp where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-07-01') and date('2020-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-07-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and sr.daydate between date('2020-07-01') and date(date_trunc('week',date('2020-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days') - --where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2020-07-01') and date('2020-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'f9ed771d-6236-f6f3-caa7-e678a49023d0') - where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and pd.daydate between date('2020-07-01') and date('2020-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '92ff737d-651b-8471-8f34-0587a39171db' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-07-14'))) as firstday , date(date_trunc('week',date('2021-08-22')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-12'::timestamp,'2021-07-25'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/2 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '10:00:00' as wdcontracthours -FROM generate_series( '2021-08-13'::timestamp,'2021-08-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '10:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/3 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '06:40:12' as wdcontracthours -FROM generate_series( '2021-08-20'::timestamp,'2021-08-22'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '06:40:12'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and (daydate > date('2021-08-22') or daydate < date('2021-07-12')) - OR (id_staff='92ff737d-651b-8471-8f34-0587a39171db' AND daydate not between date('2021-07-12') and date('2021-07-25') AND daydate not between date('2021-08-13') and date('2021-08-14') AND daydate not between date('2021-08-20') and date('2021-08-22')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by rp.startdate,rp.enddate) - sper ) prp where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-09-01') and date('2020-10-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and sr.daydate between date('2020-09-01') and date(date_trunc('week',date('2020-10-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days') - --where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2020-09-01') and date('2020-10-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '1f489513-7b98-efb4-d16d-f3baeceb846a') - where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and pd.daydate between date('2020-09-01') and date('2020-10-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '92ff737d-651b-8471-8f34-0587a39171db' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-07-14'))) as firstday , date(date_trunc('week',date('2021-08-22')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-12'::timestamp,'2021-07-25'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/2 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '10:00:00' as wdcontracthours -FROM generate_series( '2021-08-13'::timestamp,'2021-08-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '10:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/3 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '06:40:12' as wdcontracthours -FROM generate_series( '2021-08-20'::timestamp,'2021-08-22'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '06:40:12'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and (daydate > date('2021-08-22') or daydate < date('2021-07-12')) - OR (id_staff='92ff737d-651b-8471-8f34-0587a39171db' AND daydate not between date('2021-07-12') and date('2021-07-25') AND daydate not between date('2021-08-13') and date('2021-08-14') AND daydate not between date('2021-08-20') and date('2021-08-22')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by rp.startdate,rp.enddate) - sper ) prp where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-11-01') and date('2020-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-11-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and sr.daydate between date('2020-11-01') and date(date_trunc('week',date('2020-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days') - --where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2020-11-01') and date('2020-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '83f75caf-b28e-5c31-cd74-d7a7bd23e960') - where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and pd.daydate between date('2020-11-01') and date('2020-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '92ff737d-651b-8471-8f34-0587a39171db' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-07-14'))) as firstday , date(date_trunc('week',date('2021-08-22')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-12'::timestamp,'2021-07-25'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/2 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '10:00:00' as wdcontracthours -FROM generate_series( '2021-08-13'::timestamp,'2021-08-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '10:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/3 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '06:40:12' as wdcontracthours -FROM generate_series( '2021-08-20'::timestamp,'2021-08-22'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '06:40:12'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and (daydate > date('2021-08-22') or daydate < date('2021-07-12')) - OR (id_staff='92ff737d-651b-8471-8f34-0587a39171db' AND daydate not between date('2021-07-12') and date('2021-07-25') AND daydate not between date('2021-08-13') and date('2021-08-14') AND daydate not between date('2021-08-20') and date('2021-08-22')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by rp.startdate,rp.enddate) - sper ) prp where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-01-01') and date('2021-02-28') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and sr.daydate between date('2021-01-01') and date(date_trunc('week',date('2021-02-28')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days') - --where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2021-01-01') and date('2021-02-28') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'da4487e9-aaf6-ee29-0718-0e6b61ab9ebc') - where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and pd.daydate between date('2021-01-01') and date('2021-02-28') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '92ff737d-651b-8471-8f34-0587a39171db' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='d85f8825-82dc-ff12-24c3-94e2967d22c0'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-07-14'))) as firstday , date(date_trunc('week',date('2021-08-22')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-12'::timestamp,'2021-07-25'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/2 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '10:00:00' as wdcontracthours -FROM generate_series( '2021-08-13'::timestamp,'2021-08-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '10:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/3 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '06:40:12' as wdcontracthours -FROM generate_series( '2021-08-20'::timestamp,'2021-08-22'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '06:40:12'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and (daydate > date('2021-08-22') or daydate < date('2021-07-12')) - OR (id_staff='92ff737d-651b-8471-8f34-0587a39171db' AND daydate not between date('2021-07-12') and date('2021-07-25') AND daydate not between date('2021-08-13') and date('2021-08-14') AND daydate not between date('2021-08-20') and date('2021-08-22')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='d85f8825-82dc-ff12-24c3-94e2967d22c0'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by rp.startdate,rp.enddate) - sper ) prp where id='d85f8825-82dc-ff12-24c3-94e2967d22c0'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-03-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-03-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-03-01') and date('2021-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-03-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and sr.daydate between date('2021-03-01') and date(date_trunc('week',date('2021-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-03-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days') - --where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2021-03-01') and date('2021-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd85f8825-82dc-ff12-24c3-94e2967d22c0') - where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and pd.daydate between date('2021-03-01') and date('2021-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '92ff737d-651b-8471-8f34-0587a39171db' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-07-14'))) as firstday , date(date_trunc('week',date('2021-08-22')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-12'::timestamp,'2021-07-25'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/2 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '10:00:00' as wdcontracthours -FROM generate_series( '2021-08-13'::timestamp,'2021-08-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '10:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/3 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '06:40:12' as wdcontracthours -FROM generate_series( '2021-08-20'::timestamp,'2021-08-22'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '06:40:12'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and (daydate > date('2021-08-22') or daydate < date('2021-07-12')) - OR (id_staff='92ff737d-651b-8471-8f34-0587a39171db' AND daydate not between date('2021-07-12') and date('2021-07-25') AND daydate not between date('2021-08-13') and date('2021-08-14') AND daydate not between date('2021-08-20') and date('2021-08-22')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by rp.startdate,rp.enddate) - sper ) prp where id='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-06-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-06-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-05-01') and date('2021-06-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and sr.daydate between date('2021-05-01') and date(date_trunc('week',date('2021-06-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-06-30')) + interval '6 days') - --where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2021-05-01') and date('2021-06-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1') - where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and pd.daydate between date('2021-05-01') and date('2021-06-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '92ff737d-651b-8471-8f34-0587a39171db' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-07-14'))) as firstday , date(date_trunc('week',date('2021-08-22')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-12'::timestamp,'2021-07-25'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/2 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '10:00:00' as wdcontracthours -FROM generate_series( '2021-08-13'::timestamp,'2021-08-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '10:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/3 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '06:40:12' as wdcontracthours -FROM generate_series( '2021-08-20'::timestamp,'2021-08-22'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '06:40:12'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and (daydate > date('2021-08-22') or daydate < date('2021-07-12')) - OR (id_staff='92ff737d-651b-8471-8f34-0587a39171db' AND daydate not between date('2021-07-12') and date('2021-07-25') AND daydate not between date('2021-08-13') and date('2021-08-14') AND daydate not between date('2021-08-20') and date('2021-08-22')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by rp.startdate,rp.enddate) - sper ) prp where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-07-01') and date('2021-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-07-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and sr.daydate between date('2021-07-01') and date(date_trunc('week',date('2021-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days') - --where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2021-07-01') and date('2021-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=3,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-08-23'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a0538335-1f82-8312-8a62-2e42ea74ed20') - where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and pd.daydate between date('2021-07-01') and date('2021-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '92ff737d-651b-8471-8f34-0587a39171db' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-07-14'))) as firstday , date(date_trunc('week',date('2021-08-22')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-12'::timestamp,'2021-07-25'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/2 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '10:00:00' as wdcontracthours -FROM generate_series( '2021-08-13'::timestamp,'2021-08-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '10:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/3 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '06:40:12' as wdcontracthours -FROM generate_series( '2021-08-20'::timestamp,'2021-08-22'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '06:40:12'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and (daydate > date('2021-08-22') or daydate < date('2021-07-12')) - OR (id_staff='92ff737d-651b-8471-8f34-0587a39171db' AND daydate not between date('2021-07-12') and date('2021-07-25') AND daydate not between date('2021-08-13') and date('2021-08-14') AND daydate not between date('2021-08-20') and date('2021-08-22')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by rp.startdate,rp.enddate) - sper ) prp where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-09-01') and date('2021-10-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and sr.daydate between date('2021-09-01') and date(date_trunc('week',date('2021-10-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days') - --where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2021-09-01') and date('2021-10-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'ec6261df-f5df-d1b9-7ca1-639d79e82bfe') - where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and pd.daydate between date('2021-09-01') and date('2021-10-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '92ff737d-651b-8471-8f34-0587a39171db' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-07-14'))) as firstday , date(date_trunc('week',date('2021-08-22')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-12'::timestamp,'2021-07-25'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/2 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '10:00:00' as wdcontracthours -FROM generate_series( '2021-08-13'::timestamp,'2021-08-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '10:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/3 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '06:40:12' as wdcontracthours -FROM generate_series( '2021-08-20'::timestamp,'2021-08-22'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '06:40:12'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and (daydate > date('2021-08-22') or daydate < date('2021-07-12')) - OR (id_staff='92ff737d-651b-8471-8f34-0587a39171db' AND daydate not between date('2021-07-12') and date('2021-07-25') AND daydate not between date('2021-08-13') and date('2021-08-14') AND daydate not between date('2021-08-20') and date('2021-08-22')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by rp.startdate,rp.enddate) - sper ) prp where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-11-01') and date('2021-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-11-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and sr.daydate between date('2021-11-01') and date(date_trunc('week',date('2021-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days') - --where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2021-11-01') and date('2021-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd1fe1b59-0129-bb85-53da-a4f9f69d9b83') - where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and pd.daydate between date('2021-11-01') and date('2021-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '92ff737d-651b-8471-8f34-0587a39171db' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-07-14'))) as firstday , date(date_trunc('week',date('2021-08-22')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-12'::timestamp,'2021-07-25'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/2 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '10:00:00' as wdcontracthours -FROM generate_series( '2021-08-13'::timestamp,'2021-08-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '10:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/3 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '06:40:12' as wdcontracthours -FROM generate_series( '2021-08-20'::timestamp,'2021-08-22'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '06:40:12'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and (daydate > date('2021-08-22') or daydate < date('2021-07-12')) - OR (id_staff='92ff737d-651b-8471-8f34-0587a39171db' AND daydate not between date('2021-07-12') and date('2021-07-25') AND daydate not between date('2021-08-13') and date('2021-08-14') AND daydate not between date('2021-08-20') and date('2021-08-22')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by rp.startdate,rp.enddate) - sper ) prp where id='35fda5d9-36ef-528b-4339-286589719039'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2022-01-01') and date('2022-06-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and sr.daydate between date('2022-01-01') and date(date_trunc('week',date('2022-06-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days') - --where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2022-01-01') and date('2022-06-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '35fda5d9-36ef-528b-4339-286589719039') - where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and pd.daydate between date('2022-01-01') and date('2022-06-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '92ff737d-651b-8471-8f34-0587a39171db' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id from kraeltgen.reportperiod order by startdate,enddate; -QUERYARRAY: select id,startdate,enddate from kraeltgen.reportperiod where -startdate >= date((select min(startdate) from kraeltgen.staffcontract where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c')) -or date((select min(startdate) from kraeltgen.staffcontract where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c')) between startdate and enddate order by startdate,enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-13'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-08-09'::timestamp,'2021-08-26'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '05:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/1 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '05:00:00' as wdcontracthours -FROM generate_series( '2021-10-03'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '05:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and (daydate > date('2022-07-03') or daydate < date('2021-08-09')) - OR (id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' AND daydate not between date('2021-08-09') and date('2021-08-26') AND daydate not between date('2021-10-03') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('a0538335-1f82-8312-8a62-2e42ea74ed20','e3ed2959-a411-2f14-b40a-27251d8f6d0c') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-13'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-08-09'::timestamp,'2021-08-26'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '05:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/1 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '05:00:00' as wdcontracthours -FROM generate_series( '2021-10-03'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '05:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and (daydate > date('2022-07-03') or daydate < date('2021-08-09')) - OR (id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' AND daydate not between date('2021-08-09') and date('2021-08-26') AND daydate not between date('2021-10-03') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('ec6261df-f5df-d1b9-7ca1-639d79e82bfe','e3ed2959-a411-2f14-b40a-27251d8f6d0c') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-13'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-08-09'::timestamp,'2021-08-26'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '05:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/1 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '05:00:00' as wdcontracthours -FROM generate_series( '2021-10-03'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '05:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and (daydate > date('2022-07-03') or daydate < date('2021-08-09')) - OR (id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' AND daydate not between date('2021-08-09') and date('2021-08-26') AND daydate not between date('2021-10-03') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('d1fe1b59-0129-bb85-53da-a4f9f69d9b83','e3ed2959-a411-2f14-b40a-27251d8f6d0c') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-13'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-08-09'::timestamp,'2021-08-26'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '05:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/1 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '05:00:00' as wdcontracthours -FROM generate_series( '2021-10-03'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '05:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and (daydate > date('2022-07-03') or daydate < date('2021-08-09')) - OR (id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' AND daydate not between date('2021-08-09') and date('2021-08-26') AND daydate not between date('2021-10-03') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('35fda5d9-36ef-528b-4339-286589719039','e3ed2959-a411-2f14-b40a-27251d8f6d0c') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select reportperiodunit,reportperiodlength from public.companies where schemata='kraeltgen' -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ) scx where startdate < enddate and id='a0538335-1f82-8312-8a62-2e42ea74ed20' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-08-13'),date('2021-08-26'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 10 as maxdays,10 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2021-07-01') and date('2021-08-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-08-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-08-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=10,contracthours='80:00:00' where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select * from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by rp.startdate,rp.enddate) - sper ) prp where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-07-01') and date('2021-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-07-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and sr.daydate between date('2021-07-01') and date(date_trunc('week',date('2021-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days') - --where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2021-07-01') and date('2021-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-08-30'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a0538335-1f82-8312-8a62-2e42ea74ed20') - where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and pd.daydate between date('2021-07-01') and date('2021-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ) scx where startdate < enddate and id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2,3,4,5,6) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-10-03'),date('2021-10-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 5 as maxdays,5 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2021-09-01') and date('2021-10-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-10-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-10-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=5,contracthours='25:00:00' where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -QUERY: select * from kraeltgen.reportperiod where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by rp.startdate,rp.enddate) - sper ) prp where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='a0538335-1f82-8312-8a62-2e42ea74ed20' and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,1+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-09-01') and date('2021-10-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,1+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and sr.daydate between date('2021-08-30') and date(date_trunc('week',date('2021-10-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days') - --where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2021-09-01') and date('2021-10-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=6,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2021-10-25'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'ec6261df-f5df-d1b9-7ca1-639d79e82bfe') - where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and pd.daydate between date('2021-09-01') and date('2021-10-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ) scx where startdate < enddate and id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2,3,4,5,6) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-11-01'),date('2021-12-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 8 as maxdays,8 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2021-11-01') and date('2021-12-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-12-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-12-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=8,contracthours='40:00:00' where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -QUERY: select * from kraeltgen.reportperiod where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by rp.startdate,rp.enddate) - sper ) prp where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='ec6261df-f5df-d1b9-7ca1-639d79e82bfe' and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,6+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-11-01') and date('2021-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-11-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,2+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and sr.daydate between date('2021-10-25') and date(date_trunc('week',date('2021-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days') - --where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2021-11-01') and date('2021-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=13,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=4,last44date=date('2021-12-27'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd1fe1b59-0129-bb85-53da-a4f9f69d9b83') - where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and pd.daydate between date('2021-11-01') and date('2021-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ) scx where startdate < enddate and id='35fda5d9-36ef-528b-4339-286589719039' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2,3,4,5,6) then 0 else 1 end as dow from pg_catalog.generate_series(date('2022-01-01'),date('2022-06-30'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 26 as maxdays,26 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2022-01-01') and date('2022-06-30') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2022-06-30') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2022-06-30')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=26,contracthours='130:00:00' where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod='35fda5d9-36ef-528b-4339-286589719039'; -QUERY: select * from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by rp.startdate,rp.enddate) - sper ) prp where id='35fda5d9-36ef-528b-4339-286589719039'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='d1fe1b59-0129-bb85-53da-a4f9f69d9b83' and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,13+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2022-01-01') and date('2022-06-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,4+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and sr.daydate between date('2021-12-27') and date(date_trunc('week',date('2022-06-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days') - --where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2022-01-01') and date('2022-06-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=19,suppvacancysunwork=null,suppvacancy44hours=1,status44hcount=1,last44date=date('2022-03-07'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '35fda5d9-36ef-528b-4339-286589719039') - where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and pd.daydate between date('2022-01-01') and date('2022-06-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -EXEC: insert into kraeltgen.staffvacancyyear (id_staff,vacyear) - select id_staff,to_char(daydate,'YYYY')::int4 as vyear from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by id_staff,vyear order by id_staff,vyear - on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-13'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-08-09'::timestamp,'2021-08-26'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '05:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/1 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '05:00:00' as wdcontracthours -FROM generate_series( '2021-10-03'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '05:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and (daydate > date('2022-07-03') or daydate < date('2021-08-09')) - OR (id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' AND daydate not between date('2021-08-09') and date('2021-08-26') AND daydate not between date('2021-10-03') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by rp.startdate,rp.enddate) - sper ) prp where id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-01-01'))) and date(date_trunc('week',date('2020-02-29')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-01-01'))) and date(date_trunc('week',date('2020-02-29')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-01-01') and date('2020-02-29') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and sr.daydate between date('2020-01-01') and date(date_trunc('week',date('2020-02-29')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-01-01'))) and date(date_trunc('week',date('2020-02-29')) + interval '6 days') - --where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2020-01-01') and date('2020-02-29') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '529236a0-bb8e-c0dd-6dfd-406fe2f59aff') - where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and pd.daydate between date('2020-01-01') and date('2020-02-29') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='872690b5-74c8-6eb3-2c9c-2ad47ea57995'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-13'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-08-09'::timestamp,'2021-08-26'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '05:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/1 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '05:00:00' as wdcontracthours -FROM generate_series( '2021-10-03'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '05:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and (daydate > date('2022-07-03') or daydate < date('2021-08-09')) - OR (id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' AND daydate not between date('2021-08-09') and date('2021-08-26') AND daydate not between date('2021-10-03') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='872690b5-74c8-6eb3-2c9c-2ad47ea57995'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by rp.startdate,rp.enddate) - sper ) prp where id='872690b5-74c8-6eb3-2c9c-2ad47ea57995'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-03-01'))) and date(date_trunc('week',date('2020-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-03-01'))) and date(date_trunc('week',date('2020-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-03-01') and date('2020-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-03-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and sr.daydate between date('2020-03-01') and date(date_trunc('week',date('2020-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-03-01'))) and date(date_trunc('week',date('2020-04-30')) + interval '6 days') - --where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2020-03-01') and date('2020-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '872690b5-74c8-6eb3-2c9c-2ad47ea57995') - where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and pd.daydate between date('2020-03-01') and date('2020-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='c70d0d68-b69f-2b02-cec3-d82b47eca9b6'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-13'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-08-09'::timestamp,'2021-08-26'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '05:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/1 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '05:00:00' as wdcontracthours -FROM generate_series( '2021-10-03'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '05:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and (daydate > date('2022-07-03') or daydate < date('2021-08-09')) - OR (id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' AND daydate not between date('2021-08-09') and date('2021-08-26') AND daydate not between date('2021-10-03') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='c70d0d68-b69f-2b02-cec3-d82b47eca9b6'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by rp.startdate,rp.enddate) - sper ) prp where id='c70d0d68-b69f-2b02-cec3-d82b47eca9b6'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-05-01'))) and date(date_trunc('week',date('2020-06-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-05-01'))) and date(date_trunc('week',date('2020-06-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-05-01') and date('2020-06-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and sr.daydate between date('2020-05-01') and date(date_trunc('week',date('2020-06-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-05-01'))) and date(date_trunc('week',date('2020-06-30')) + interval '6 days') - --where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2020-05-01') and date('2020-06-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'c70d0d68-b69f-2b02-cec3-d82b47eca9b6') - where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and pd.daydate between date('2020-05-01') and date('2020-06-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-13'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-08-09'::timestamp,'2021-08-26'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '05:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/1 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '05:00:00' as wdcontracthours -FROM generate_series( '2021-10-03'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '05:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and (daydate > date('2022-07-03') or daydate < date('2021-08-09')) - OR (id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' AND daydate not between date('2021-08-09') and date('2021-08-26') AND daydate not between date('2021-10-03') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by rp.startdate,rp.enddate) - sper ) prp where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-07-01') and date('2020-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-07-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and sr.daydate between date('2020-07-01') and date(date_trunc('week',date('2020-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days') - --where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2020-07-01') and date('2020-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'f9ed771d-6236-f6f3-caa7-e678a49023d0') - where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and pd.daydate between date('2020-07-01') and date('2020-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-13'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-08-09'::timestamp,'2021-08-26'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '05:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/1 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '05:00:00' as wdcontracthours -FROM generate_series( '2021-10-03'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '05:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and (daydate > date('2022-07-03') or daydate < date('2021-08-09')) - OR (id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' AND daydate not between date('2021-08-09') and date('2021-08-26') AND daydate not between date('2021-10-03') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by rp.startdate,rp.enddate) - sper ) prp where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-09-01') and date('2020-10-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and sr.daydate between date('2020-09-01') and date(date_trunc('week',date('2020-10-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days') - --where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2020-09-01') and date('2020-10-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '1f489513-7b98-efb4-d16d-f3baeceb846a') - where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and pd.daydate between date('2020-09-01') and date('2020-10-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-13'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-08-09'::timestamp,'2021-08-26'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '05:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/1 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '05:00:00' as wdcontracthours -FROM generate_series( '2021-10-03'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '05:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and (daydate > date('2022-07-03') or daydate < date('2021-08-09')) - OR (id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' AND daydate not between date('2021-08-09') and date('2021-08-26') AND daydate not between date('2021-10-03') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by rp.startdate,rp.enddate) - sper ) prp where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-11-01') and date('2020-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-11-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and sr.daydate between date('2020-11-01') and date(date_trunc('week',date('2020-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days') - --where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2020-11-01') and date('2020-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '83f75caf-b28e-5c31-cd74-d7a7bd23e960') - where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and pd.daydate between date('2020-11-01') and date('2020-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-13'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-08-09'::timestamp,'2021-08-26'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '05:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/1 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '05:00:00' as wdcontracthours -FROM generate_series( '2021-10-03'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '05:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and (daydate > date('2022-07-03') or daydate < date('2021-08-09')) - OR (id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' AND daydate not between date('2021-08-09') and date('2021-08-26') AND daydate not between date('2021-10-03') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by rp.startdate,rp.enddate) - sper ) prp where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-01-01') and date('2021-02-28') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and sr.daydate between date('2021-01-01') and date(date_trunc('week',date('2021-02-28')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days') - --where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2021-01-01') and date('2021-02-28') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'da4487e9-aaf6-ee29-0718-0e6b61ab9ebc') - where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and pd.daydate between date('2021-01-01') and date('2021-02-28') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='d85f8825-82dc-ff12-24c3-94e2967d22c0'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-13'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-08-09'::timestamp,'2021-08-26'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '05:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/1 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '05:00:00' as wdcontracthours -FROM generate_series( '2021-10-03'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '05:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and (daydate > date('2022-07-03') or daydate < date('2021-08-09')) - OR (id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' AND daydate not between date('2021-08-09') and date('2021-08-26') AND daydate not between date('2021-10-03') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='d85f8825-82dc-ff12-24c3-94e2967d22c0'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by rp.startdate,rp.enddate) - sper ) prp where id='d85f8825-82dc-ff12-24c3-94e2967d22c0'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-03-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-03-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-03-01') and date('2021-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-03-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and sr.daydate between date('2021-03-01') and date(date_trunc('week',date('2021-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-03-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days') - --where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2021-03-01') and date('2021-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd85f8825-82dc-ff12-24c3-94e2967d22c0') - where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and pd.daydate between date('2021-03-01') and date('2021-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-13'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-08-09'::timestamp,'2021-08-26'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '05:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/1 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '05:00:00' as wdcontracthours -FROM generate_series( '2021-10-03'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '05:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and (daydate > date('2022-07-03') or daydate < date('2021-08-09')) - OR (id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' AND daydate not between date('2021-08-09') and date('2021-08-26') AND daydate not between date('2021-10-03') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by rp.startdate,rp.enddate) - sper ) prp where id='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-06-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-06-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-05-01') and date('2021-06-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and sr.daydate between date('2021-05-01') and date(date_trunc('week',date('2021-06-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-06-30')) + interval '6 days') - --where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2021-05-01') and date('2021-06-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1') - where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and pd.daydate between date('2021-05-01') and date('2021-06-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-13'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-08-09'::timestamp,'2021-08-26'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '05:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/1 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '05:00:00' as wdcontracthours -FROM generate_series( '2021-10-03'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '05:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and (daydate > date('2022-07-03') or daydate < date('2021-08-09')) - OR (id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' AND daydate not between date('2021-08-09') and date('2021-08-26') AND daydate not between date('2021-10-03') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by rp.startdate,rp.enddate) - sper ) prp where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-07-01') and date('2021-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-07-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and sr.daydate between date('2021-07-01') and date(date_trunc('week',date('2021-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days') - --where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2021-07-01') and date('2021-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-08-30'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a0538335-1f82-8312-8a62-2e42ea74ed20') - where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and pd.daydate between date('2021-07-01') and date('2021-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-13'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-08-09'::timestamp,'2021-08-26'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '05:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/1 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '05:00:00' as wdcontracthours -FROM generate_series( '2021-10-03'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '05:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and (daydate > date('2022-07-03') or daydate < date('2021-08-09')) - OR (id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' AND daydate not between date('2021-08-09') and date('2021-08-26') AND daydate not between date('2021-10-03') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by rp.startdate,rp.enddate) - sper ) prp where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='a0538335-1f82-8312-8a62-2e42ea74ed20' and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,1+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-09-01') and date('2021-10-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,1+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and sr.daydate between date('2021-08-30') and date(date_trunc('week',date('2021-10-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days') - --where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2021-09-01') and date('2021-10-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=6,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2021-10-25'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'ec6261df-f5df-d1b9-7ca1-639d79e82bfe') - where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and pd.daydate between date('2021-09-01') and date('2021-10-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-13'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-08-09'::timestamp,'2021-08-26'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '05:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/1 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '05:00:00' as wdcontracthours -FROM generate_series( '2021-10-03'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '05:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and (daydate > date('2022-07-03') or daydate < date('2021-08-09')) - OR (id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' AND daydate not between date('2021-08-09') and date('2021-08-26') AND daydate not between date('2021-10-03') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by rp.startdate,rp.enddate) - sper ) prp where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='ec6261df-f5df-d1b9-7ca1-639d79e82bfe' and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,6+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-11-01') and date('2021-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-11-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,2+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and sr.daydate between date('2021-10-25') and date(date_trunc('week',date('2021-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days') - --where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2021-11-01') and date('2021-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=13,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=4,last44date=date('2021-12-27'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd1fe1b59-0129-bb85-53da-a4f9f69d9b83') - where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and pd.daydate between date('2021-11-01') and date('2021-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-13'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-08-09'::timestamp,'2021-08-26'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '05:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/1 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '05:00:00' as wdcontracthours -FROM generate_series( '2021-10-03'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '05:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and (daydate > date('2022-07-03') or daydate < date('2021-08-09')) - OR (id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' AND daydate not between date('2021-08-09') and date('2021-08-26') AND daydate not between date('2021-10-03') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by rp.startdate,rp.enddate) - sper ) prp where id='35fda5d9-36ef-528b-4339-286589719039'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='d1fe1b59-0129-bb85-53da-a4f9f69d9b83' and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,13+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2022-01-01') and date('2022-06-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,4+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and sr.daydate between date('2021-12-27') and date(date_trunc('week',date('2022-06-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days') - --where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2022-01-01') and date('2022-06-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=19,suppvacancysunwork=null,suppvacancy44hours=1,status44hcount=1,last44date=date('2022-03-07'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '35fda5d9-36ef-528b-4339-286589719039') - where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and pd.daydate between date('2022-01-01') and date('2022-06-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id from kraeltgen.reportperiod order by startdate,enddate; -QUERYARRAY: select id,startdate,enddate from kraeltgen.reportperiod where -startdate >= date((select min(startdate) from kraeltgen.staffcontract where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c')) -or date((select min(startdate) from kraeltgen.staffcontract where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c')) between startdate and enddate order by startdate,enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2019-12-30'))) as firstday , date(date_trunc('week',date('2021-08-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2019-12-30'::timestamp,'2021-09-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and (daydate > date('2021-09-05') or daydate < date('2019-12-30')) - OR (id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' AND daydate not between date('2019-12-30') and date('2021-09-05')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('529236a0-bb8e-c0dd-6dfd-406fe2f59aff','2eec5d6c-2cc6-cb11-3439-596e210dea5c') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='872690b5-74c8-6eb3-2c9c-2ad47ea57995'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2019-12-30'))) as firstday , date(date_trunc('week',date('2021-08-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2019-12-30'::timestamp,'2021-09-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and (daydate > date('2021-09-05') or daydate < date('2019-12-30')) - OR (id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' AND daydate not between date('2019-12-30') and date('2021-09-05')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('872690b5-74c8-6eb3-2c9c-2ad47ea57995','2eec5d6c-2cc6-cb11-3439-596e210dea5c') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='c70d0d68-b69f-2b02-cec3-d82b47eca9b6'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2019-12-30'))) as firstday , date(date_trunc('week',date('2021-08-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2019-12-30'::timestamp,'2021-09-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and (daydate > date('2021-09-05') or daydate < date('2019-12-30')) - OR (id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' AND daydate not between date('2019-12-30') and date('2021-09-05')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('c70d0d68-b69f-2b02-cec3-d82b47eca9b6','2eec5d6c-2cc6-cb11-3439-596e210dea5c') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2019-12-30'))) as firstday , date(date_trunc('week',date('2021-08-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2019-12-30'::timestamp,'2021-09-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and (daydate > date('2021-09-05') or daydate < date('2019-12-30')) - OR (id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' AND daydate not between date('2019-12-30') and date('2021-09-05')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('f9ed771d-6236-f6f3-caa7-e678a49023d0','2eec5d6c-2cc6-cb11-3439-596e210dea5c') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2019-12-30'))) as firstday , date(date_trunc('week',date('2021-08-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2019-12-30'::timestamp,'2021-09-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and (daydate > date('2021-09-05') or daydate < date('2019-12-30')) - OR (id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' AND daydate not between date('2019-12-30') and date('2021-09-05')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('1f489513-7b98-efb4-d16d-f3baeceb846a','2eec5d6c-2cc6-cb11-3439-596e210dea5c') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2019-12-30'))) as firstday , date(date_trunc('week',date('2021-08-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2019-12-30'::timestamp,'2021-09-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and (daydate > date('2021-09-05') or daydate < date('2019-12-30')) - OR (id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' AND daydate not between date('2019-12-30') and date('2021-09-05')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('83f75caf-b28e-5c31-cd74-d7a7bd23e960','2eec5d6c-2cc6-cb11-3439-596e210dea5c') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2019-12-30'))) as firstday , date(date_trunc('week',date('2021-08-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2019-12-30'::timestamp,'2021-09-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and (daydate > date('2021-09-05') or daydate < date('2019-12-30')) - OR (id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' AND daydate not between date('2019-12-30') and date('2021-09-05')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('da4487e9-aaf6-ee29-0718-0e6b61ab9ebc','2eec5d6c-2cc6-cb11-3439-596e210dea5c') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='d85f8825-82dc-ff12-24c3-94e2967d22c0'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2019-12-30'))) as firstday , date(date_trunc('week',date('2021-08-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2019-12-30'::timestamp,'2021-09-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and (daydate > date('2021-09-05') or daydate < date('2019-12-30')) - OR (id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' AND daydate not between date('2019-12-30') and date('2021-09-05')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('d85f8825-82dc-ff12-24c3-94e2967d22c0','2eec5d6c-2cc6-cb11-3439-596e210dea5c') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2019-12-30'))) as firstday , date(date_trunc('week',date('2021-08-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2019-12-30'::timestamp,'2021-09-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and (daydate > date('2021-09-05') or daydate < date('2019-12-30')) - OR (id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' AND daydate not between date('2019-12-30') and date('2021-09-05')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1','2eec5d6c-2cc6-cb11-3439-596e210dea5c') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2019-12-30'))) as firstday , date(date_trunc('week',date('2021-08-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2019-12-30'::timestamp,'2021-09-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and (daydate > date('2021-09-05') or daydate < date('2019-12-30')) - OR (id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' AND daydate not between date('2019-12-30') and date('2021-09-05')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('a0538335-1f82-8312-8a62-2e42ea74ed20','2eec5d6c-2cc6-cb11-3439-596e210dea5c') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2019-12-30'))) as firstday , date(date_trunc('week',date('2021-08-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2019-12-30'::timestamp,'2021-09-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and (daydate > date('2021-09-05') or daydate < date('2019-12-30')) - OR (id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' AND daydate not between date('2019-12-30') and date('2021-09-05')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('ec6261df-f5df-d1b9-7ca1-639d79e82bfe','2eec5d6c-2cc6-cb11-3439-596e210dea5c') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2019-12-30'))) as firstday , date(date_trunc('week',date('2021-08-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2019-12-30'::timestamp,'2021-09-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and (daydate > date('2021-09-05') or daydate < date('2019-12-30')) - OR (id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' AND daydate not between date('2019-12-30') and date('2021-09-05')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('d1fe1b59-0129-bb85-53da-a4f9f69d9b83','2eec5d6c-2cc6-cb11-3439-596e210dea5c') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2019-12-30'))) as firstday , date(date_trunc('week',date('2021-08-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2019-12-30'::timestamp,'2021-09-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and (daydate > date('2021-09-05') or daydate < date('2019-12-30')) - OR (id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' AND daydate not between date('2019-12-30') and date('2021-09-05')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('35fda5d9-36ef-528b-4339-286589719039','2eec5d6c-2cc6-cb11-3439-596e210dea5c') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select reportperiodunit,reportperiodlength from public.companies where schemata='kraeltgen' -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) scx where startdate < enddate and id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2020-01-01'),date('2020-02-29'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 44 as maxdays,44 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2020-01-01') and date('2020-02-29') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2020-02-29') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2020-02-29')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=44,contracthours='352:00:00' where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -QUERY: select * from kraeltgen.reportperiod where id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by rp.startdate,rp.enddate) - sper ) prp where id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-01-01'))) and date(date_trunc('week',date('2020-02-29')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-01-01'))) and date(date_trunc('week',date('2020-02-29')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-01-01') and date('2020-02-29') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and sr.daydate between date('2020-01-01') and date(date_trunc('week',date('2020-02-29')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-01-01'))) and date(date_trunc('week',date('2020-02-29')) + interval '6 days') - --where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2020-01-01') and date('2020-02-29') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=8,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2020-02-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '529236a0-bb8e-c0dd-6dfd-406fe2f59aff') - where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and pd.daydate between date('2020-01-01') and date('2020-02-29') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) scx where startdate < enddate and id='872690b5-74c8-6eb3-2c9c-2ad47ea57995' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2020-03-01'),date('2020-04-30'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 43 as maxdays,43 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2020-03-01') and date('2020-04-30') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2020-04-30') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2020-04-30')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=43,contracthours='344:00:00' where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod='872690b5-74c8-6eb3-2c9c-2ad47ea57995'; -QUERY: select * from kraeltgen.reportperiod where id='872690b5-74c8-6eb3-2c9c-2ad47ea57995'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by rp.startdate,rp.enddate) - sper ) prp where id='872690b5-74c8-6eb3-2c9c-2ad47ea57995'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-03-01'))) and date(date_trunc('week',date('2020-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-03-01'))) and date(date_trunc('week',date('2020-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='529236a0-bb8e-c0dd-6dfd-406fe2f59aff' and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,8+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-03-01') and date('2020-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-03-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,1+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and sr.daydate between date('2020-02-24') and date(date_trunc('week',date('2020-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-03-01'))) and date(date_trunc('week',date('2020-04-30')) + interval '6 days') - --where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2020-03-01') and date('2020-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=10,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2020-03-16'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '872690b5-74c8-6eb3-2c9c-2ad47ea57995') - where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and pd.daydate between date('2020-03-01') and date('2020-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) scx where startdate < enddate and id='c70d0d68-b69f-2b02-cec3-d82b47eca9b6' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2020-05-01'),date('2020-06-30'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 43 as maxdays,43 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2020-05-01') and date('2020-06-30') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2020-06-30') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2020-06-30')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=43,contracthours='344:00:00' where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod='c70d0d68-b69f-2b02-cec3-d82b47eca9b6'; -QUERY: select * from kraeltgen.reportperiod where id='c70d0d68-b69f-2b02-cec3-d82b47eca9b6'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by rp.startdate,rp.enddate) - sper ) prp where id='c70d0d68-b69f-2b02-cec3-d82b47eca9b6'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-05-01'))) and date(date_trunc('week',date('2020-06-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-05-01'))) and date(date_trunc('week',date('2020-06-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='872690b5-74c8-6eb3-2c9c-2ad47ea57995' and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,10+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-05-01') and date('2020-06-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,2+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and sr.daydate between date('2020-03-16') and date(date_trunc('week',date('2020-06-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-05-01'))) and date(date_trunc('week',date('2020-06-30')) + interval '6 days') - --where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2020-05-01') and date('2020-06-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'c70d0d68-b69f-2b02-cec3-d82b47eca9b6') - where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and pd.daydate between date('2020-05-01') and date('2020-06-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) scx where startdate < enddate and id='f9ed771d-6236-f6f3-caa7-e678a49023d0' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2020-07-01'),date('2020-08-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 45 as maxdays,45 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2020-07-01') and date('2020-08-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2020-08-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2020-08-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=45,contracthours='360:00:00' where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -QUERY: select * from kraeltgen.reportperiod where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by rp.startdate,rp.enddate) - sper ) prp where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='c70d0d68-b69f-2b02-cec3-d82b47eca9b6' and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-07-01') and date('2020-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-07-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and sr.daydate between date('2020-07-01') and date(date_trunc('week',date('2020-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days') - --where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2020-07-01') and date('2020-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'f9ed771d-6236-f6f3-caa7-e678a49023d0') - where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and pd.daydate between date('2020-07-01') and date('2020-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) scx where startdate < enddate and id='1f489513-7b98-efb4-d16d-f3baeceb846a' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2020-09-01'),date('2020-10-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 44 as maxdays,44 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2020-09-01') and date('2020-10-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2020-10-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2020-10-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=44,contracthours='352:00:00' where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod='1f489513-7b98-efb4-d16d-f3baeceb846a'; -QUERY: select * from kraeltgen.reportperiod where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by rp.startdate,rp.enddate) - sper ) prp where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='f9ed771d-6236-f6f3-caa7-e678a49023d0' and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-09-01') and date('2020-10-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and sr.daydate between date('2020-09-01') and date(date_trunc('week',date('2020-10-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days') - --where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2020-09-01') and date('2020-10-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=7,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=4,last44date=date('2020-10-26'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '1f489513-7b98-efb4-d16d-f3baeceb846a') - where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and pd.daydate between date('2020-09-01') and date('2020-10-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) scx where startdate < enddate and id='83f75caf-b28e-5c31-cd74-d7a7bd23e960' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2020-11-01'),date('2020-12-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 43 as maxdays,43 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2020-11-01') and date('2020-12-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2020-12-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2020-12-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=43,contracthours='344:00:00' where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -QUERY: select * from kraeltgen.reportperiod where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by rp.startdate,rp.enddate) - sper ) prp where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='1f489513-7b98-efb4-d16d-f3baeceb846a' and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,7+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-11-01') and date('2020-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-11-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,4+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and sr.daydate between date('2020-10-26') and date(date_trunc('week',date('2020-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days') - --where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2020-11-01') and date('2020-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=8,suppvacancysunwork=null,suppvacancy44hours=1,status44hcount=4,last44date=date('2020-12-28'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '83f75caf-b28e-5c31-cd74-d7a7bd23e960') - where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and pd.daydate between date('2020-11-01') and date('2020-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) scx where startdate < enddate and id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-01-01'),date('2021-02-28'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 43 as maxdays,43 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2021-01-01') and date('2021-02-28') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-02-28') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-02-28')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=43,contracthours='344:00:00' where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -QUERY: select * from kraeltgen.reportperiod where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by rp.startdate,rp.enddate) - sper ) prp where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='83f75caf-b28e-5c31-cd74-d7a7bd23e960' and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,8+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-01-01') and date('2021-02-28') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,4+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and sr.daydate between date('2020-12-28') and date(date_trunc('week',date('2021-02-28')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days') - --where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2021-01-01') and date('2021-02-28') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=13,suppvacancysunwork=null,suppvacancy44hours=1,status44hcount=2,last44date=date('2021-02-22'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(pd.nighthours) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'da4487e9-aaf6-ee29-0718-0e6b61ab9ebc') - where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and pd.daydate between date('2021-01-01') and date('2021-02-28') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) scx where startdate < enddate and id='d85f8825-82dc-ff12-24c3-94e2967d22c0' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-03-01'),date('2021-04-30'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 43 as maxdays,43 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2021-03-01') and date('2021-04-30') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-04-30') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-04-30')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=43,contracthours='344:00:00' where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod='d85f8825-82dc-ff12-24c3-94e2967d22c0'; -QUERY: select * from kraeltgen.reportperiod where id='d85f8825-82dc-ff12-24c3-94e2967d22c0'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by rp.startdate,rp.enddate) - sper ) prp where id='d85f8825-82dc-ff12-24c3-94e2967d22c0'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2021-03-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2021-03-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc' and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,13+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-03-01') and date('2021-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-03-01'))); -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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_reportperiod = 'd1fe1b59-0129-bb85-53da-a4f9f69d9b83' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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_reportperiod = '35fda5d9-36ef-528b-4339-286589719039' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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_reportperiod = 'd1fe1b59-0129-bb85-53da-a4f9f69d9b83' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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_reportperiod = '35fda5d9-36ef-528b-4339-286589719039' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039' -QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff - ,to_char(ws.workhours::interval,'HH24:MI') as workhours - ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal - ,to_char(ws.vacillhours,'HH24:MI') as vacancyill - ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra - ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours - ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours - ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours - ,to_char(ws.totalhours,'HH24:MI') as totalhours - ,cd.contractworkdays - ,cd.cmpcontractdays - ,cd.cmpweekhours - ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours - ,ws.periodworkhours - ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff - ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours - ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff - ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours - ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours - ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours - ,case when cd.contractworkdays < cd.cmpcontractdays then - to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI') - else - to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI') - end as maxweekhours - ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else - to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI') - end as defaultweekhours - from ( - SELECT weekstart,weekend,calweek,calyear, id_staff, - sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours, - sum(case when srpd.daydate between date('2022-01-01') and date('2022-06-30') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours, - --sum(case when srpd.daydate between date('2022-01-01') and date('2022-06-30') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause, - sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours, - sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours, - sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours, - sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours, - sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours, - sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours, - sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours, - sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays, - sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2021-12-27') and date('2022-07-03') - ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff - ORDER BY weekstart) ws left join ( - select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours, - case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays, - case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays - from ( select id_staff,weekdays ,weekhours, - case when startdate> date('2021-12-27') then startdate else date('2021-12-27') end as staffperiodstart, - case when enddate is null or enddate > date('2022-07-03') then date('2022-07-03') - else enddate end as staffperiodend from kraeltgen.staffcontract where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - and startdate < date('2022-07-03') - ) sc - join kraeltgen.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend) - group by date(date_trunc('week',pd.daydate)),pd.id_staff - ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart - left join ( - select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from ( - select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate, - case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours , - case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours - from kraeltgen.staffreportperioddays lpd - left join kraeltgen.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate) - cross join (select * from kraeltgen.worktimes where isdefault=true) wkdef - where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and lpd.daydate between date('2021-12-27') and date('2022-07-03') - order by lpd.daydate ) mh group by id_staff,weekstart - ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart - left join ( - select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from ( - select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from ( -select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from kraeltgen.timetracker -where daydate between date('2022-01-01') and date('2022-06-30') and id_staff ='2eec5d6c-2cc6-cb11-3439-596e210dea5c') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff - ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment, - vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment, - date(date_trunc('week',pd.daydate)) as weekstart, - to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1, - to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1, - to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2, - to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2, - to_char(pd.timepause::interval, 'HH24:MI') AS timepause, - -- coalesce('
' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '
','') AS dspvacancyhours, - to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours, - to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours, - to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours, - to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours, - to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours, - to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours, - to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours, - to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours, - to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours, - to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours, - to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours, - to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1, - to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1, - to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2, - to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2, - COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata, - COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata, - CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter, - to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours, - to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours, - to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation, - to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours, - max(vd.vacancyname) as vacancyname, - to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime, - interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff, - max(tt.incompletetrack) as incompletetrack - FROM kraeltgen.staffreportperioddays pd - JOIN kraeltgen.staff st ON pd.id_staff = st.id and st.id='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and st.isdeleted is null - LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto, - yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval, - date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate - left join kraeltgen.worktimes wk on pd.daydate between wk.startdate and wk.enddate - cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from kraeltgen.worktimes where isdefault =true) wkstd - left join kraeltgen.vacancydays vd on pd.daydate=vd.daydate - left join ( - select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime, - sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack -from kraeltgen.timetracker where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2021-12-27') and date('2022-07-03') group by daydate - ) tt on pd.daydate=tt.daydate - WHERE pd.daydate between date('2021-12-27') and date('2022-07-03') - group by pd.id - ORDER BY pd.id_staff, pd.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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_reportperiod = '35fda5d9-36ef-528b-4339-286589719039' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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.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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' 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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from kraeltgen.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='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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='2eec5d6c-2cc6-cb11-3439-596e210dea5c' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' 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='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by startdate,enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '2eec5d6c-2cc6-cb11-3439-596e210dea5c' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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.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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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 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 id,trackername from kraeltgen.timetrackerconfig order by trackername -QUERYARRAY: select ttr.*, st.* ,stg.groupname,'' || COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' 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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from kraeltgen.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='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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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.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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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 kraeltgen.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 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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_reportperiod = '529236a0-bb8e-c0dd-6dfd-406fe2f59aff' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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_reportperiod = '35fda5d9-36ef-528b-4339-286589719039' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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_reportperiod = 'd1fe1b59-0129-bb85-53da-a4f9f69d9b83' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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_reportperiod = 'ec6261df-f5df-d1b9-7ca1-639d79e82bfe' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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_reportperiod = 'a0538335-1f82-8312-8a62-2e42ea74ed20' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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_reportperiod = '529236a0-bb8e-c0dd-6dfd-406fe2f59aff' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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_reportperiod = '872690b5-74c8-6eb3-2c9c-2ad47ea57995' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from kraeltgen.reportperiod where id='872690b5-74c8-6eb3-2c9c-2ad47ea57995' -QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff - ,to_char(ws.workhours::interval,'HH24:MI') as workhours - ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal - ,to_char(ws.vacillhours,'HH24:MI') as vacancyill - ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra - ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours - ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours - ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours - ,to_char(ws.totalhours,'HH24:MI') as totalhours - ,cd.contractworkdays - ,cd.cmpcontractdays - ,cd.cmpweekhours - ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours - ,ws.periodworkhours - ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff - ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours - ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff - ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours - ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours - ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours - ,case when cd.contractworkdays < cd.cmpcontractdays then - to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI') - else - to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI') - end as maxweekhours - ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else - to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI') - end as defaultweekhours - from ( - SELECT weekstart,weekend,calweek,calyear, id_staff, - sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours, - sum(case when srpd.daydate between date('2020-03-01') and date('2020-04-30') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours, - --sum(case when srpd.daydate between date('2020-03-01') and date('2020-04-30') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause, - sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours, - sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours, - sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours, - sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours, - sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours, - sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours, - sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours, - sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays, - sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2020-02-24') and date('2020-05-03') - ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff - ORDER BY weekstart) ws left join ( - select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours, - case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays, - case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays - from ( select id_staff,weekdays ,weekhours, - case when startdate> date('2020-02-24') then startdate else date('2020-02-24') end as staffperiodstart, - case when enddate is null or enddate > date('2020-05-03') then date('2020-05-03') - else enddate end as staffperiodend from kraeltgen.staffcontract where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - and startdate < date('2020-05-03') - ) sc - join kraeltgen.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend) - group by date(date_trunc('week',pd.daydate)),pd.id_staff - ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart - left join ( - select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from ( - select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate, - case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours , - case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours - from kraeltgen.staffreportperioddays lpd - left join kraeltgen.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate) - cross join (select * from kraeltgen.worktimes where isdefault=true) wkdef - where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and lpd.daydate between date('2020-02-24') and date('2020-05-03') - order by lpd.daydate ) mh group by id_staff,weekstart - ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart - left join ( - select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from ( - select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from ( -select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from kraeltgen.timetracker -where daydate between date('2020-03-01') and date('2020-04-30') and id_staff ='2eec5d6c-2cc6-cb11-3439-596e210dea5c') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff - ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment, - vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment, - date(date_trunc('week',pd.daydate)) as weekstart, - to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1, - to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1, - to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2, - to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2, - to_char(pd.timepause::interval, 'HH24:MI') AS timepause, - -- coalesce('
' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '
','') AS dspvacancyhours, - to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours, - to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours, - to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours, - to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours, - to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours, - to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours, - to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours, - to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours, - to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours, - to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours, - to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours, - to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1, - to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1, - to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2, - to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2, - COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata, - COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata, - CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter, - to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours, - to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours, - to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation, - to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours, - max(vd.vacancyname) as vacancyname, - to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime, - interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff, - max(tt.incompletetrack) as incompletetrack - FROM kraeltgen.staffreportperioddays pd - JOIN kraeltgen.staff st ON pd.id_staff = st.id and st.id='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and st.isdeleted is null - LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto, - yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval, - date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate - left join kraeltgen.worktimes wk on pd.daydate between wk.startdate and wk.enddate - cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from kraeltgen.worktimes where isdefault =true) wkstd - left join kraeltgen.vacancydays vd on pd.daydate=vd.daydate - left join ( - select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime, - sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack -from kraeltgen.timetracker where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2020-02-24') and date('2020-05-03') group by daydate - ) tt on pd.daydate=tt.daydate - WHERE pd.daydate between date('2020-02-24') and date('2020-05-03') - group by pd.id - ORDER BY pd.id_staff, pd.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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_reportperiod = '872690b5-74c8-6eb3-2c9c-2ad47ea57995' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: 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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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 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(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' 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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from kraeltgen.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='kraeltgen') ttr -where st.isdeleted is null order by groupname,st.staffnumber,surname,prename; -QUERYARRAY: select id,trackername from kraeltgen.timetrackerconfig order by trackername -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='2eec5d6c-2cc6-cb11-3439-596e210dea5c' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '2eec5d6c-2cc6-cb11-3439-596e210dea5c' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' 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='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by startdate,enddate; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='a3ae61bb-a890-70cf-97a5-f3379f446d1e' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'a3ae61bb-a890-70cf-97a5-f3379f446d1e' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -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='a3ae61bb-a890-70cf-97a5-f3379f446d1e' order by startdate,enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'a3ae61bb-a890-70cf-97a5-f3379f446d1e' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -,'),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='a3ae61bb-a890-70cf-97a5-f3379f446d1e' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='a3ae61bb-a890-70cf-97a5-f3379f446d1e' order by vacyear; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -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='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' order by startdate,enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='92ff737d-651b-8471-8f34-0587a39171db' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -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='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '92ff737d-651b-8471-8f34-0587a39171db' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '92ff737d-651b-8471-8f34-0587a39171db' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by vacyear; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='92ff737d-651b-8471-8f34-0587a39171db' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='e3ed2959-a411-2f14-b40a-27251d8f6d0c' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by vacyear; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='afe52b22-342a-204a-f5c0-492ac2b23319' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'afe52b22-342a-204a-f5c0-492ac2b23319' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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='afe52b22-342a-204a-f5c0-492ac2b23319' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='afe52b22-342a-204a-f5c0-492ac2b23319' order by vacyear; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'afe52b22-342a-204a-f5c0-492ac2b23319' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='afe52b22-342a-204a-f5c0-492ac2b23319' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='5966c9c3-f97a-0cf5-2d99-6ad2aceb2dec' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='5966c9c3-f97a-0cf5-2d99-6ad2aceb2dec' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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='5966c9c3-f97a-0cf5-2d99-6ad2aceb2dec' order by startdate,enddate; -ddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '5966c9c3-f97a-0cf5-2d99-6ad2aceb2dec' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='5966c9c3-f97a-0cf5-2d99-6ad2aceb2dec' order by vacyear; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='a3ae61bb-a890-70cf-97a5-f3379f446d1e' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'a3ae61bb-a890-70cf-97a5-f3379f446d1e' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'a3ae61bb-a890-70cf-97a5-f3379f446d1e' - 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='a3ae61bb-a890-70cf-97a5-f3379f446d1e' order by vacyear; -_staff='a3ae61bb-a890-70cf-97a5-f3379f446d1e' order by startdate,enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='a3ae61bb-a890-70cf-97a5-f3379f446d1e' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='f18a67e3-1b2f-dbed-85e9-1b35912f943e' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.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' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='087ed140-8731-0792-70d1-e92e2505c44b' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='087ed140-8731-0792-70d1-e92e2505c44b' order by vacyear; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '087ed140-8731-0792-70d1-e92e2505c44b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '087ed140-8731-0792-70d1-e92e2505c44b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -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='087ed140-8731-0792-70d1-e92e2505c44b' order by startdate,enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='087ed140-8731-0792-70d1-e92e2505c44b' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -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 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='f18a67e3-1b2f-dbed-85e9-1b35912f943e' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: 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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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 kraeltgen.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 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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_reportperiod = '872690b5-74c8-6eb3-2c9c-2ad47ea57995' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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_reportperiod = 'c70d0d68-b69f-2b02-cec3-d82b47eca9b6' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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.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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate, - coalesce(to_char(spd.vacancyhours::interval,'HH24:MI'),'') as vacancyhours, - coalesce(to_char(spd.vacillhours::interval,'HH24:MI'),'') as vacillhours, - coalesce(to_char(spd.vacextrahours::interval,'HH24:MI'),'') as vacextrahours, - coalesce ( spd.vacancycomment || ' ' ,'') || coalesce( spd.vacillcomment || ' ' ,'') || coalesce( spd.vacextracomment|| ' ','') as description - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and date_trunc('month',spd.daydate)=date_trunc('month',date('2022-01-01')) order by st.surname,st.prename,spd.daydate -QUERYARRAY: select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate, - coalesce(to_char(spd.vacancyhours::interval,'HH24:MI'),'') as vacancyhours, - coalesce(to_char(spd.vacillhours::interval,'HH24:MI'),'') as vacillhours, - coalesce(to_char(spd.vacextrahours::interval,'HH24:MI'),'') as vacextrahours, - coalesce ( spd.vacancycomment || ' ' ,'') || coalesce( spd.vacillcomment || ' ' ,'') || coalesce( spd.vacextracomment|| ' ','') as description - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and date_trunc('month',spd.daydate)=date_trunc('month',date('2022-01-01')) order by st.surname,st.prename,spd.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: 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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and date_trunc('year',spd.daydate)=date_trunc('year',date('2022-01-01')) - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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.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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' 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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from kraeltgen.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='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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='20b53171-4182-d837-21b7-33ef52d49329' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '20b53171-4182-d837-21b7-33ef52d49329' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '20b53171-4182-d837-21b7-33ef52d49329' - 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='20b53171-4182-d837-21b7-33ef52d49329' order by vacyear; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='20b53171-4182-d837-21b7-33ef52d49329' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '20b53171-4182-d837-21b7-33ef52d49329' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '20b53171-4182-d837-21b7-33ef52d49329' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '20b53171-4182-d837-21b7-33ef52d49329' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '20b53171-4182-d837-21b7-33ef52d49329' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '20b53171-4182-d837-21b7-33ef52d49329' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '20b53171-4182-d837-21b7-33ef52d49329' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '20b53171-4182-d837-21b7-33ef52d49329' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '20b53171-4182-d837-21b7-33ef52d49329' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' 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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from kraeltgen.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='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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='087ed140-8731-0792-70d1-e92e2505c44b' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '087ed140-8731-0792-70d1-e92e2505c44b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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='087ed140-8731-0792-70d1-e92e2505c44b' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='087ed140-8731-0792-70d1-e92e2505c44b' order by vacyear; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='087ed140-8731-0792-70d1-e92e2505c44b' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '087ed140-8731-0792-70d1-e92e2505c44b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='a3ae61bb-a890-70cf-97a5-f3379f446d1e' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'a3ae61bb-a890-70cf-97a5-f3379f446d1e' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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='a3ae61bb-a890-70cf-97a5-f3379f446d1e' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='a3ae61bb-a890-70cf-97a5-f3379f446d1e' order by vacyear; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'a3ae61bb-a890-70cf-97a5-f3379f446d1e' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='a3ae61bb-a890-70cf-97a5-f3379f446d1e' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' order by vacyear; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='3ea6073d-3f9c-7106-b30e-aa8502884fb6' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -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='3ea6073d-3f9c-7106-b30e-aa8502884fb6' order by startdate,enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '3ea6073d-3f9c-7106-b30e-aa8502884fb6' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '3ea6073d-3f9c-7106-b30e-aa8502884fb6' - 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='3ea6073d-3f9c-7106-b30e-aa8502884fb6' order by vacyear; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='3ea6073d-3f9c-7106-b30e-aa8502884fb6' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='e3ed2959-a411-2f14-b40a-27251d8f6d0c' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -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='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by vacyear; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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 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 id,trackername from kraeltgen.timetrackerconfig order by trackername -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select ttr.*, st.* ,stg.groupname,'' || COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' 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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from kraeltgen.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='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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='087ed140-8731-0792-70d1-e92e2505c44b' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '087ed140-8731-0792-70d1-e92e2505c44b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -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='087ed140-8731-0792-70d1-e92e2505c44b' order by startdate,enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='087ed140-8731-0792-70d1-e92e2505c44b' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='087ed140-8731-0792-70d1-e92e2505c44b' order by vacyear; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '087ed140-8731-0792-70d1-e92e2505c44b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='a3ae61bb-a890-70cf-97a5-f3379f446d1e' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'a3ae61bb-a890-70cf-97a5-f3379f446d1e' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -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='a3ae61bb-a890-70cf-97a5-f3379f446d1e' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='a3ae61bb-a890-70cf-97a5-f3379f446d1e' order by vacyear; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'a3ae61bb-a890-70cf-97a5-f3379f446d1e' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='a3ae61bb-a890-70cf-97a5-f3379f446d1e' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' order by vacyear; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='3ea6073d-3f9c-7106-b30e-aa8502884fb6' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -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='3ea6073d-3f9c-7106-b30e-aa8502884fb6' order by startdate,enddate; -cyhours, '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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '3ea6073d-3f9c-7106-b30e-aa8502884fb6' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='3ea6073d-3f9c-7106-b30e-aa8502884fb6' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '3ea6073d-3f9c-7106-b30e-aa8502884fb6' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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 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 ttr.*, st.* ,stg.groupname,'' || COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' 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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from kraeltgen.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='kraeltgen') ttr -where st.isdeleted is null order by groupname,st.staffnumber,surname,prename; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='20b53171-4182-d837-21b7-33ef52d49329' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '20b53171-4182-d837-21b7-33ef52d49329' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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='20b53171-4182-d837-21b7-33ef52d49329' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='20b53171-4182-d837-21b7-33ef52d49329' order by vacyear; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '20b53171-4182-d837-21b7-33ef52d49329' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='20b53171-4182-d837-21b7-33ef52d49329' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='73f003c0-4912-7c00-e38a-ce42f36bbbfb' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '73f003c0-4912-7c00-e38a-ce42f36bbbfb' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='73f003c0-4912-7c00-e38a-ce42f36bbbfb' order by vacyear; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='73f003c0-4912-7c00-e38a-ce42f36bbbfb' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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='73f003c0-4912-7c00-e38a-ce42f36bbbfb' order by startdate,enddate; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '73f003c0-4912-7c00-e38a-ce42f36bbbfb' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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 ttr.*, st.* ,stg.groupname,'' || COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' 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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from kraeltgen.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='kraeltgen') ttr -where st.isdeleted is null order by groupname,st.staffnumber,surname,prename; -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 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='a3ae61bb-a890-70cf-97a5-f3379f446d1e' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportpeQUERYARRAY: 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='a3ae61bb-a890-70cf-97a5-f3379f446d1e' order by startdate,enddate; -har(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'a3ae61bb-a890-70cf-97a5-f3379f446d1e' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'a3ae61bb-a890-70cf-97a5-f3379f446d1e' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='a3ae61bb-a890-70cf-97a5-f3379f446d1e' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -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='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' order by vacyear; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='3ea6073d-3f9c-7106-b30e-aa8502884fb6' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '3ea6073d-3f9c-7106-b30e-aa8502884fb6' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '3ea6073d-3f9c-7106-b30e-aa8502884fb6' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -en mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='3ea6073d-3f9c-7106-b30e-aa8502884fb6' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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='3ea6073d-3f9c-7106-b30e-aa8502884fb6' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='3ea6073d-3f9c-7106-b30e-aa8502884fb6' order by vacyear; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='e3ed2959-a411-2f14-b40a-27251d8f6d0c' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -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='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -ddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -,'),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='afe52b22-342a-204a-f5c0-492ac2b23319' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -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='afe52b22-342a-204a-f5c0-492ac2b23319' order by startdate,enddate; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'afe52b22-342a-204a-f5c0-492ac2b23319' - 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='afe52b22-342a-204a-f5c0-492ac2b23319' order by vacyear; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='afe52b22-342a-204a-f5c0-492ac2b23319' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'afe52b22-342a-204a-f5c0-492ac2b23319' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='e3ed2959-a411-2f14-b40a-27251d8f6d0c' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -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='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by vacyear; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='a3ae61bb-a890-70cf-97a5-f3379f446d1e' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -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='a3ae61bb-a890-70cf-97a5-f3379f446d1e' order by startdate,enddate; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'a3ae61bb-a890-70cf-97a5-f3379f446d1e' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'a3ae61bb-a890-70cf-97a5-f3379f446d1e' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='a3ae61bb-a890-70cf-97a5-f3379f446d1e' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='a3ae61bb-a890-70cf-97a5-f3379f446d1e' order by vacyear; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -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='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' order by vacyear; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='f90f0cc3-7a37-f6e0-fa25-0d63aee82147' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='3ea6073d-3f9c-7106-b30e-aa8502884fb6' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -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='3ea6073d-3f9c-7106-b30e-aa8502884fb6' order by startdate,enddate; -cyhours, '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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '3ea6073d-3f9c-7106-b30e-aa8502884fb6' - 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='3ea6073d-3f9c-7106-b30e-aa8502884fb6' order by vacyear; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='3ea6073d-3f9c-7106-b30e-aa8502884fb6' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '3ea6073d-3f9c-7106-b30e-aa8502884fb6' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='f94fd7b0-6921-c0a0-7e69-08fe1175ba9b' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -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='f94fd7b0-6921-c0a0-7e69-08fe1175ba9b' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='f94fd7b0-6921-c0a0-7e69-08fe1175ba9b' order by vacyear; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f94fd7b0-6921-c0a0-7e69-08fe1175ba9b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'f94fd7b0-6921-c0a0-7e69-08fe1175ba9b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='f94fd7b0-6921-c0a0-7e69-08fe1175ba9b' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='7969b272-ba37-e27a-b374-f8ae12278a7f' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from kraeltgen.staffreportperioddays spd - join kraeltgen.staff st on (st.id=spd.id_staff) - join kraeltgen.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='7969b272-ba37-e27a-b374-f8ae12278a7f' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='7969b272-ba37-e27a-b374-f8ae12278a7f' order by vacyear; -_staff='7969b272-ba37-e27a-b374-f8ae12278a7f' order by startdate,enddate; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '7969b272-ba37-e27a-b374-f8ae12278a7f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '7969b272-ba37-e27a-b374-f8ae12278a7f' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '7969b272-ba37-e27a-b374-f8ae12278a7f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '7969b272-ba37-e27a-b374-f8ae12278a7f' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '7969b272-ba37-e27a-b374-f8ae12278a7f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '7969b272-ba37-e27a-b374-f8ae12278a7f' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '7969b272-ba37-e27a-b374-f8ae12278a7f' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '7969b272-ba37-e27a-b374-f8ae12278a7f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '7969b272-ba37-e27a-b374-f8ae12278a7f' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '7969b272-ba37-e27a-b374-f8ae12278a7f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '7969b272-ba37-e27a-b374-f8ae12278a7f' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '7969b272-ba37-e27a-b374-f8ae12278a7f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '7969b272-ba37-e27a-b374-f8ae12278a7f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '7969b272-ba37-e27a-b374-f8ae12278a7f' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '7969b272-ba37-e27a-b374-f8ae12278a7f' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '7969b272-ba37-e27a-b374-f8ae12278a7f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '7969b272-ba37-e27a-b374-f8ae12278a7f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '7969b272-ba37-e27a-b374-f8ae12278a7f' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '7969b272-ba37-e27a-b374-f8ae12278a7f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from kraeltgen.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from kraeltgen.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join kraeltgen.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - join kraeltgen.staff st on (pd.id_staff=st.id) - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '7969b272-ba37-e27a-b374-f8ae12278a7f' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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.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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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 kraeltgen.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 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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_reportperiod = '529236a0-bb8e-c0dd-6dfd-406fe2f59aff' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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_reportperiod = '1f489513-7b98-efb4-d16d-f3baeceb846a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: 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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select sessiondata from public.sessions where id='6cfa9047-f585-a84b-62b0-0e0a53c9fd08' -EXEC: update public.sessions set sessiondata='{"schemata":"lousdiner"}' where id='6cfa9047-f585-a84b-62b0-0e0a53c9fd08' -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: 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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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 lousdiner.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 lousdiner.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = '6748aadc-7171-bc73-a0b3-e097b8fa8716' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id from lousdiner.staff where isdeleted is null; -QUERYARRAY: select id from lousdiner.reportperiod order by startdate,enddate; -QUERYARRAY: select id,startdate,enddate from lousdiner.reportperiod where -startdate >= date((select min(startdate) from lousdiner.staffcontract where id_staff='ae108794-eb2b-836d-7348-50f30bea5204')) -or date((select min(startdate) from lousdiner.staffcontract where id_staff='ae108794-eb2b-836d-7348-50f30bea5204')) between startdate and enddate order by startdate,enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='ae108794-eb2b-836d-7348-50f30bea5204' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('bec92b1d-4b99-4aad-ddcb-a693b929acd7','ae108794-eb2b-836d-7348-50f30bea5204') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='ae108794-eb2b-836d-7348-50f30bea5204' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('6748aadc-7171-bc73-a0b3-e097b8fa8716','ae108794-eb2b-836d-7348-50f30bea5204') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='ae108794-eb2b-836d-7348-50f30bea5204' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8','ae108794-eb2b-836d-7348-50f30bea5204') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='ae108794-eb2b-836d-7348-50f30bea5204' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('d6b04e48-367a-6b0b-0aa2-d8f956df55e2','ae108794-eb2b-836d-7348-50f30bea5204') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select reportperiodunit,reportperiodlength from public.companies where schemata='lousdiner' -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' - ) scx where startdate < enddate and id='bec92b1d-4b99-4aad-ddcb-a693b929acd7' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-02-01'),date('2021-07-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 130 as maxdays,130 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date('2021-02-01') and date('2021-07-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-07-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-07-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=130,contracthours='1040:00:00' where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by rp.startdate,rp.enddate) - sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-02-01') and date('2021-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days') - --where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date('2021-02-01') and date('2021-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7') - where pd.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and pd.daydate between date('2021-02-01') and date('2021-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ae108794-eb2b-836d-7348-50f30bea5204' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' - ) scx where startdate < enddate and id='6748aadc-7171-bc73-a0b3-e097b8fa8716' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-08-01'),date('2022-01-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 131 as maxdays,131 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date('2021-08-01') and date('2022-01-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2022-01-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2022-01-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=131,contracthours='1048:00:00' where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select * from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by rp.startdate,rp.enddate) - sper ) prp where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='bec92b1d-4b99-4aad-ddcb-a693b929acd7' and id_staff='ae108794-eb2b-836d-7348-50f30bea5204'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-08-01') and date('2022-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and sr.daydate between date('2021-08-01') and date(date_trunc('week',date('2022-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days') - --where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date('2021-08-01') and date('2022-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '6748aadc-7171-bc73-a0b3-e097b8fa8716') - where pd.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and pd.daydate between date('2021-08-01') and date('2022-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ae108794-eb2b-836d-7348-50f30bea5204' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' - ) scx where startdate < enddate and id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2022-02-01'),date('2022-07-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 129 as maxdays,129 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date('2022-02-01') and date('2022-07-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2022-07-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2022-07-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=129,contracthours='1032:00:00' where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select * from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by rp.startdate,rp.enddate) - sper ) prp where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='6748aadc-7171-bc73-a0b3-e097b8fa8716' and id_staff='ae108794-eb2b-836d-7348-50f30bea5204'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-02-01') and date('2022-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and sr.daydate between date('2022-02-01') and date(date_trunc('week',date('2022-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days') - --where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date('2022-02-01') and date('2022-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8') - where pd.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and pd.daydate between date('2022-02-01') and date('2022-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ae108794-eb2b-836d-7348-50f30bea5204' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' - ) scx where startdate < enddate and id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2022-08-01'),date('2023-01-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 132 as maxdays,132 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date('2022-08-01') and date('2023-01-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2023-01-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2023-01-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=132,contracthours='1056:00:00' where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select * from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by rp.startdate,rp.enddate) - sper ) prp where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' and id_staff='ae108794-eb2b-836d-7348-50f30bea5204'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-08-01') and date('2023-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and sr.daydate between date('2022-08-01') and date(date_trunc('week',date('2023-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days') - --where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date('2022-08-01') and date('2023-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd6b04e48-367a-6b0b-0aa2-d8f956df55e2') - where pd.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and pd.daydate between date('2022-08-01') and date('2023-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ae108794-eb2b-836d-7348-50f30bea5204' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -EXEC: insert into lousdiner.staffvacancyyear (id_staff,vacyear) - select id_staff,to_char(daydate,'YYYY')::int4 as vyear from lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' group by id_staff,vyear order by id_staff,vyear - on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='ae108794-eb2b-836d-7348-50f30bea5204' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by rp.startdate,rp.enddate) - sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-02-01') and date('2021-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days') - --where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date('2021-02-01') and date('2021-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7') - where pd.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and pd.daydate between date('2021-02-01') and date('2021-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ae108794-eb2b-836d-7348-50f30bea5204' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='ae108794-eb2b-836d-7348-50f30bea5204' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by rp.startdate,rp.enddate) - sper ) prp where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='bec92b1d-4b99-4aad-ddcb-a693b929acd7' and id_staff='ae108794-eb2b-836d-7348-50f30bea5204'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-08-01') and date('2022-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and sr.daydate between date('2021-08-01') and date(date_trunc('week',date('2022-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days') - --where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date('2021-08-01') and date('2022-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '6748aadc-7171-bc73-a0b3-e097b8fa8716') - where pd.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and pd.daydate between date('2021-08-01') and date('2022-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ae108794-eb2b-836d-7348-50f30bea5204' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='ae108794-eb2b-836d-7348-50f30bea5204' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by rp.startdate,rp.enddate) - sper ) prp where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='6748aadc-7171-bc73-a0b3-e097b8fa8716' and id_staff='ae108794-eb2b-836d-7348-50f30bea5204'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-02-01') and date('2022-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and sr.daydate between date('2022-02-01') and date(date_trunc('week',date('2022-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days') - --where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date('2022-02-01') and date('2022-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8') - where pd.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and pd.daydate between date('2022-02-01') and date('2022-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ae108794-eb2b-836d-7348-50f30bea5204' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='ae108794-eb2b-836d-7348-50f30bea5204' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by rp.startdate,rp.enddate) - sper ) prp where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' and id_staff='ae108794-eb2b-836d-7348-50f30bea5204'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-08-01') and date('2023-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and sr.daydate between date('2022-08-01') and date(date_trunc('week',date('2023-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days') - --where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date('2022-08-01') and date('2023-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd6b04e48-367a-6b0b-0aa2-d8f956df55e2') - where pd.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and pd.daydate between date('2022-08-01') and date('2023-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ae108794-eb2b-836d-7348-50f30bea5204' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id from lousdiner.reportperiod order by startdate,enddate; -QUERYARRAY: select id,startdate,enddate from lousdiner.reportperiod where -startdate >= date((select min(startdate) from lousdiner.staffcontract where id_staff='45270017-c671-2912-5dde-6febfabb2668')) -or date((select min(startdate) from lousdiner.staffcontract where id_staff='45270017-c671-2912-5dde-6febfabb2668')) between startdate and enddate order by startdate,enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'45270017-c671-2912-5dde-6febfabb2668' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='45270017-c671-2912-5dde-6febfabb2668' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'45270017-c671-2912-5dde-6febfabb2668' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='45270017-c671-2912-5dde-6febfabb2668' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='45270017-c671-2912-5dde-6febfabb2668' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('bec92b1d-4b99-4aad-ddcb-a693b929acd7','45270017-c671-2912-5dde-6febfabb2668') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'45270017-c671-2912-5dde-6febfabb2668' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='45270017-c671-2912-5dde-6febfabb2668' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'45270017-c671-2912-5dde-6febfabb2668' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='45270017-c671-2912-5dde-6febfabb2668' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='45270017-c671-2912-5dde-6febfabb2668' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('6748aadc-7171-bc73-a0b3-e097b8fa8716','45270017-c671-2912-5dde-6febfabb2668') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'45270017-c671-2912-5dde-6febfabb2668' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='45270017-c671-2912-5dde-6febfabb2668' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'45270017-c671-2912-5dde-6febfabb2668' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='45270017-c671-2912-5dde-6febfabb2668' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='45270017-c671-2912-5dde-6febfabb2668' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8','45270017-c671-2912-5dde-6febfabb2668') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'45270017-c671-2912-5dde-6febfabb2668' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='45270017-c671-2912-5dde-6febfabb2668' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'45270017-c671-2912-5dde-6febfabb2668' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='45270017-c671-2912-5dde-6febfabb2668' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='45270017-c671-2912-5dde-6febfabb2668' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('d6b04e48-367a-6b0b-0aa2-d8f956df55e2','45270017-c671-2912-5dde-6febfabb2668') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select reportperiodunit,reportperiodlength from public.companies where schemata='lousdiner' -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='45270017-c671-2912-5dde-6febfabb2668' - ) scx where startdate < enddate and id='bec92b1d-4b99-4aad-ddcb-a693b929acd7' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-02-01'),date('2021-07-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 130 as maxdays,130 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date('2021-02-01') and date('2021-07-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-07-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-07-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='45270017-c671-2912-5dde-6febfabb2668' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=130,contracthours='1040:00:00' where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='45270017-c671-2912-5dde-6febfabb2668' order by rp.startdate,rp.enddate) - sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-02-01') and date('2021-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='45270017-c671-2912-5dde-6febfabb2668' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='45270017-c671-2912-5dde-6febfabb2668' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days') - --where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date('2021-02-01') and date('2021-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-07-26'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7') - where pd.id_staff='45270017-c671-2912-5dde-6febfabb2668' and pd.daydate between date('2021-02-01') and date('2021-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '45270017-c671-2912-5dde-6febfabb2668' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='45270017-c671-2912-5dde-6febfabb2668' - ) scx where startdate < enddate and id='6748aadc-7171-bc73-a0b3-e097b8fa8716' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-08-01'),date('2022-01-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 131 as maxdays,131 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date('2021-08-01') and date('2022-01-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2022-01-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2022-01-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='45270017-c671-2912-5dde-6febfabb2668' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=131,contracthours='1048:00:00' where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select * from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='45270017-c671-2912-5dde-6febfabb2668' order by rp.startdate,rp.enddate) - sper ) prp where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='bec92b1d-4b99-4aad-ddcb-a693b929acd7' and id_staff='45270017-c671-2912-5dde-6febfabb2668'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-08-01') and date('2022-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='45270017-c671-2912-5dde-6febfabb2668' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,1+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='45270017-c671-2912-5dde-6febfabb2668' and sr.daydate between date('2021-07-26') and date(date_trunc('week',date('2022-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days') - --where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date('2021-08-01') and date('2022-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2021-08-02'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '6748aadc-7171-bc73-a0b3-e097b8fa8716') - where pd.id_staff='45270017-c671-2912-5dde-6febfabb2668' and pd.daydate between date('2021-08-01') and date('2022-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '45270017-c671-2912-5dde-6febfabb2668' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='45270017-c671-2912-5dde-6febfabb2668' - ) scx where startdate < enddate and id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2022-02-01'),date('2022-07-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 129 as maxdays,129 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date('2022-02-01') and date('2022-07-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2022-07-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2022-07-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='45270017-c671-2912-5dde-6febfabb2668' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=129,contracthours='1032:00:00' where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select * from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='45270017-c671-2912-5dde-6febfabb2668' order by rp.startdate,rp.enddate) - sper ) prp where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='6748aadc-7171-bc73-a0b3-e097b8fa8716' and id_staff='45270017-c671-2912-5dde-6febfabb2668'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-02-01') and date('2022-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='45270017-c671-2912-5dde-6febfabb2668' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,2+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='45270017-c671-2912-5dde-6febfabb2668' and sr.daydate between date('2021-08-02') and date(date_trunc('week',date('2022-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days') - --where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date('2022-02-01') and date('2022-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8') - where pd.id_staff='45270017-c671-2912-5dde-6febfabb2668' and pd.daydate between date('2022-02-01') and date('2022-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '45270017-c671-2912-5dde-6febfabb2668' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='45270017-c671-2912-5dde-6febfabb2668' - ) scx where startdate < enddate and id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2022-08-01'),date('2023-01-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 132 as maxdays,132 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date('2022-08-01') and date('2023-01-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2023-01-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2023-01-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='45270017-c671-2912-5dde-6febfabb2668' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=132,contracthours='1056:00:00' where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select * from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='45270017-c671-2912-5dde-6febfabb2668' order by rp.startdate,rp.enddate) - sper ) prp where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' and id_staff='45270017-c671-2912-5dde-6febfabb2668'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-08-01') and date('2023-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='45270017-c671-2912-5dde-6febfabb2668' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='45270017-c671-2912-5dde-6febfabb2668' and sr.daydate between date('2022-08-01') and date(date_trunc('week',date('2023-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days') - --where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date('2022-08-01') and date('2023-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd6b04e48-367a-6b0b-0aa2-d8f956df55e2') - where pd.id_staff='45270017-c671-2912-5dde-6febfabb2668' and pd.daydate between date('2022-08-01') and date('2023-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '45270017-c671-2912-5dde-6febfabb2668' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -EXEC: insert into lousdiner.staffvacancyyear (id_staff,vacyear) - select id_staff,to_char(daydate,'YYYY')::int4 as vyear from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' group by id_staff,vyear order by id_staff,vyear - on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'45270017-c671-2912-5dde-6febfabb2668' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='45270017-c671-2912-5dde-6febfabb2668' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'45270017-c671-2912-5dde-6febfabb2668' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='45270017-c671-2912-5dde-6febfabb2668' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='45270017-c671-2912-5dde-6febfabb2668' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='45270017-c671-2912-5dde-6febfabb2668' order by rp.startdate,rp.enddate) - sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-02-01') and date('2021-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='45270017-c671-2912-5dde-6febfabb2668' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='45270017-c671-2912-5dde-6febfabb2668' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days') - --where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date('2021-02-01') and date('2021-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-07-26'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7') - where pd.id_staff='45270017-c671-2912-5dde-6febfabb2668' and pd.daydate between date('2021-02-01') and date('2021-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '45270017-c671-2912-5dde-6febfabb2668' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'45270017-c671-2912-5dde-6febfabb2668' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='45270017-c671-2912-5dde-6febfabb2668' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'45270017-c671-2912-5dde-6febfabb2668' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='45270017-c671-2912-5dde-6febfabb2668' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='45270017-c671-2912-5dde-6febfabb2668' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='45270017-c671-2912-5dde-6febfabb2668' order by rp.startdate,rp.enddate) - sper ) prp where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='bec92b1d-4b99-4aad-ddcb-a693b929acd7' and id_staff='45270017-c671-2912-5dde-6febfabb2668'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-08-01') and date('2022-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='45270017-c671-2912-5dde-6febfabb2668' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,1+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='45270017-c671-2912-5dde-6febfabb2668' and sr.daydate between date('2021-07-26') and date(date_trunc('week',date('2022-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days') - --where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date('2021-08-01') and date('2022-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2021-08-02'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '6748aadc-7171-bc73-a0b3-e097b8fa8716') - where pd.id_staff='45270017-c671-2912-5dde-6febfabb2668' and pd.daydate between date('2021-08-01') and date('2022-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '45270017-c671-2912-5dde-6febfabb2668' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'45270017-c671-2912-5dde-6febfabb2668' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='45270017-c671-2912-5dde-6febfabb2668' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'45270017-c671-2912-5dde-6febfabb2668' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='45270017-c671-2912-5dde-6febfabb2668' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='45270017-c671-2912-5dde-6febfabb2668' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='45270017-c671-2912-5dde-6febfabb2668' order by rp.startdate,rp.enddate) - sper ) prp where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='6748aadc-7171-bc73-a0b3-e097b8fa8716' and id_staff='45270017-c671-2912-5dde-6febfabb2668'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-02-01') and date('2022-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='45270017-c671-2912-5dde-6febfabb2668' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,2+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='45270017-c671-2912-5dde-6febfabb2668' and sr.daydate between date('2021-08-02') and date(date_trunc('week',date('2022-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days') - --where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date('2022-02-01') and date('2022-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8') - where pd.id_staff='45270017-c671-2912-5dde-6febfabb2668' and pd.daydate between date('2022-02-01') and date('2022-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '45270017-c671-2912-5dde-6febfabb2668' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'45270017-c671-2912-5dde-6febfabb2668' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='45270017-c671-2912-5dde-6febfabb2668' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'45270017-c671-2912-5dde-6febfabb2668' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='45270017-c671-2912-5dde-6febfabb2668' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='45270017-c671-2912-5dde-6febfabb2668' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='45270017-c671-2912-5dde-6febfabb2668' order by rp.startdate,rp.enddate) - sper ) prp where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' and id_staff='45270017-c671-2912-5dde-6febfabb2668'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-08-01') and date('2023-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='45270017-c671-2912-5dde-6febfabb2668' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='45270017-c671-2912-5dde-6febfabb2668' and sr.daydate between date('2022-08-01') and date(date_trunc('week',date('2023-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days') - --where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date('2022-08-01') and date('2023-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd6b04e48-367a-6b0b-0aa2-d8f956df55e2') - where pd.id_staff='45270017-c671-2912-5dde-6febfabb2668' and pd.daydate between date('2022-08-01') and date('2023-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '45270017-c671-2912-5dde-6febfabb2668' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id from lousdiner.reportperiod order by startdate,enddate; -QUERYARRAY: select id,startdate,enddate from lousdiner.reportperiod where -startdate >= date((select min(startdate) from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f')) -or date((select min(startdate) from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f')) between startdate and enddate order by startdate,enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('bec92b1d-4b99-4aad-ddcb-a693b929acd7','d439cd6a-7758-2072-9c4b-eca7639bd94f') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('6748aadc-7171-bc73-a0b3-e097b8fa8716','d439cd6a-7758-2072-9c4b-eca7639bd94f') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8','d439cd6a-7758-2072-9c4b-eca7639bd94f') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('d6b04e48-367a-6b0b-0aa2-d8f956df55e2','d439cd6a-7758-2072-9c4b-eca7639bd94f') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select reportperiodunit,reportperiodlength from public.companies where schemata='lousdiner' -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' - ) scx where startdate < enddate and id='bec92b1d-4b99-4aad-ddcb-a693b929acd7' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-02-01'),date('2021-07-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 130 as maxdays,130 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-07-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-07-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-07-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=130,contracthours='1040:00:00' where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by rp.startdate,rp.enddate) - sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-02-01') and date('2021-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days') - --where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-07-26'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7') - where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and pd.daydate between date('2021-02-01') and date('2021-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'd439cd6a-7758-2072-9c4b-eca7639bd94f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' - ) scx where startdate < enddate and id='6748aadc-7171-bc73-a0b3-e097b8fa8716' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-08-01'),date('2022-01-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 131 as maxdays,131 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-08-01') and date('2022-01-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2022-01-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2022-01-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=131,contracthours='1048:00:00' where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select * from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by rp.startdate,rp.enddate) - sper ) prp where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='bec92b1d-4b99-4aad-ddcb-a693b929acd7' and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-08-01') and date('2022-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,1+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and sr.daydate between date('2021-07-26') and date(date_trunc('week',date('2022-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days') - --where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-08-01') and date('2022-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2021-08-02'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '6748aadc-7171-bc73-a0b3-e097b8fa8716') - where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and pd.daydate between date('2021-08-01') and date('2022-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'd439cd6a-7758-2072-9c4b-eca7639bd94f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' - ) scx where startdate < enddate and id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2022-02-01'),date('2022-07-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 129 as maxdays,129 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2022-02-01') and date('2022-07-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2022-07-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2022-07-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=129,contracthours='1032:00:00' where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select * from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by rp.startdate,rp.enddate) - sper ) prp where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='6748aadc-7171-bc73-a0b3-e097b8fa8716' and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-02-01') and date('2022-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,2+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and sr.daydate between date('2021-08-02') and date(date_trunc('week',date('2022-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days') - --where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2022-02-01') and date('2022-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8') - where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and pd.daydate between date('2022-02-01') and date('2022-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'd439cd6a-7758-2072-9c4b-eca7639bd94f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' - ) scx where startdate < enddate and id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2022-08-01'),date('2023-01-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 132 as maxdays,132 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2022-08-01') and date('2023-01-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2023-01-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2023-01-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=132,contracthours='1056:00:00' where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select * from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by rp.startdate,rp.enddate) - sper ) prp where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-08-01') and date('2023-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and sr.daydate between date('2022-08-01') and date(date_trunc('week',date('2023-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days') - --where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2022-08-01') and date('2023-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd6b04e48-367a-6b0b-0aa2-d8f956df55e2') - where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and pd.daydate between date('2022-08-01') and date('2023-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'd439cd6a-7758-2072-9c4b-eca7639bd94f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -EXEC: insert into lousdiner.staffvacancyyear (id_staff,vacyear) - select id_staff,to_char(daydate,'YYYY')::int4 as vyear from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' group by id_staff,vyear order by id_staff,vyear - on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by rp.startdate,rp.enddate) - sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-02-01') and date('2021-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days') - --where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-07-26'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7') - where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and pd.daydate between date('2021-02-01') and date('2021-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'd439cd6a-7758-2072-9c4b-eca7639bd94f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by rp.startdate,rp.enddate) - sper ) prp where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='bec92b1d-4b99-4aad-ddcb-a693b929acd7' and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-08-01') and date('2022-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,1+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and sr.daydate between date('2021-07-26') and date(date_trunc('week',date('2022-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days') - --where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-08-01') and date('2022-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2021-08-02'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '6748aadc-7171-bc73-a0b3-e097b8fa8716') - where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and pd.daydate between date('2021-08-01') and date('2022-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'd439cd6a-7758-2072-9c4b-eca7639bd94f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by rp.startdate,rp.enddate) - sper ) prp where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='6748aadc-7171-bc73-a0b3-e097b8fa8716' and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-02-01') and date('2022-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,2+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and sr.daydate between date('2021-08-02') and date(date_trunc('week',date('2022-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days') - --where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2022-02-01') and date('2022-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8') - where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and pd.daydate between date('2022-02-01') and date('2022-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'd439cd6a-7758-2072-9c4b-eca7639bd94f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by rp.startdate,rp.enddate) - sper ) prp where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-08-01') and date('2023-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and sr.daydate between date('2022-08-01') and date(date_trunc('week',date('2023-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days') - --where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2022-08-01') and date('2023-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd6b04e48-367a-6b0b-0aa2-d8f956df55e2') - where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and pd.daydate between date('2022-08-01') and date('2023-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'd439cd6a-7758-2072-9c4b-eca7639bd94f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id from lousdiner.reportperiod order by startdate,enddate; -QUERYARRAY: select id,startdate,enddate from lousdiner.reportperiod where -startdate >= date((select min(startdate) from lousdiner.staffcontract where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413')) -or date((select min(startdate) from lousdiner.staffcontract where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413')) between startdate and enddate order by startdate,enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'0bfc88e6-76fe-24a7-78b9-adbdff787413' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'0bfc88e6-76fe-24a7-78b9-adbdff787413' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('bec92b1d-4b99-4aad-ddcb-a693b929acd7','0bfc88e6-76fe-24a7-78b9-adbdff787413') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'0bfc88e6-76fe-24a7-78b9-adbdff787413' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'0bfc88e6-76fe-24a7-78b9-adbdff787413' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('6748aadc-7171-bc73-a0b3-e097b8fa8716','0bfc88e6-76fe-24a7-78b9-adbdff787413') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'0bfc88e6-76fe-24a7-78b9-adbdff787413' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'0bfc88e6-76fe-24a7-78b9-adbdff787413' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8','0bfc88e6-76fe-24a7-78b9-adbdff787413') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'0bfc88e6-76fe-24a7-78b9-adbdff787413' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'0bfc88e6-76fe-24a7-78b9-adbdff787413' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('d6b04e48-367a-6b0b-0aa2-d8f956df55e2','0bfc88e6-76fe-24a7-78b9-adbdff787413') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select reportperiodunit,reportperiodlength from public.companies where schemata='lousdiner' -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' - ) scx where startdate < enddate and id='bec92b1d-4b99-4aad-ddcb-a693b929acd7' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-02-01'),date('2021-07-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 130 as maxdays,130 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date('2021-02-01') and date('2021-07-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-07-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-07-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=130,contracthours='1040:00:00' where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by rp.startdate,rp.enddate) - sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-02-01') and date('2021-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days') - --where id_staff= '0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date('2021-02-01') and date('2021-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7') - where pd.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and pd.daydate between date('2021-02-01') and date('2021-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '0bfc88e6-76fe-24a7-78b9-adbdff787413' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' - ) scx where startdate < enddate and id='6748aadc-7171-bc73-a0b3-e097b8fa8716' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-08-01'),date('2022-01-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 131 as maxdays,131 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date('2021-08-01') and date('2022-01-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2022-01-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2022-01-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=131,contracthours='1048:00:00' where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select * from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by rp.startdate,rp.enddate) - sper ) prp where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='bec92b1d-4b99-4aad-ddcb-a693b929acd7' and id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-08-01') and date('2022-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and sr.daydate between date('2021-08-01') and date(date_trunc('week',date('2022-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days') - --where id_staff= '0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date('2021-08-01') and date('2022-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '6748aadc-7171-bc73-a0b3-e097b8fa8716') - where pd.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and pd.daydate between date('2021-08-01') and date('2022-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '0bfc88e6-76fe-24a7-78b9-adbdff787413' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' - ) scx where startdate < enddate and id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2022-02-01'),date('2022-07-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 129 as maxdays,129 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date('2022-02-01') and date('2022-07-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2022-07-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2022-07-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=129,contracthours='1032:00:00' where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select * from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by rp.startdate,rp.enddate) - sper ) prp where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='6748aadc-7171-bc73-a0b3-e097b8fa8716' and id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-02-01') and date('2022-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and sr.daydate between date('2022-02-01') and date(date_trunc('week',date('2022-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days') - --where id_staff= '0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date('2022-02-01') and date('2022-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8') - where pd.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and pd.daydate between date('2022-02-01') and date('2022-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '0bfc88e6-76fe-24a7-78b9-adbdff787413' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' - ) scx where startdate < enddate and id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2022-08-01'),date('2023-01-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 132 as maxdays,132 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date('2022-08-01') and date('2023-01-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2023-01-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2023-01-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=132,contracthours='1056:00:00' where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select * from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by rp.startdate,rp.enddate) - sper ) prp where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' and id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-08-01') and date('2023-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and sr.daydate between date('2022-08-01') and date(date_trunc('week',date('2023-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days') - --where id_staff= '0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date('2022-08-01') and date('2023-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd6b04e48-367a-6b0b-0aa2-d8f956df55e2') - where pd.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and pd.daydate between date('2022-08-01') and date('2023-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '0bfc88e6-76fe-24a7-78b9-adbdff787413' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -EXEC: insert into lousdiner.staffvacancyyear (id_staff,vacyear) - select id_staff,to_char(daydate,'YYYY')::int4 as vyear from lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' group by id_staff,vyear order by id_staff,vyear - on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'0bfc88e6-76fe-24a7-78b9-adbdff787413' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'0bfc88e6-76fe-24a7-78b9-adbdff787413' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by rp.startdate,rp.enddate) - sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-02-01') and date('2021-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days') - --where id_staff= '0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date('2021-02-01') and date('2021-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7') - where pd.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and pd.daydate between date('2021-02-01') and date('2021-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '0bfc88e6-76fe-24a7-78b9-adbdff787413' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'0bfc88e6-76fe-24a7-78b9-adbdff787413' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'0bfc88e6-76fe-24a7-78b9-adbdff787413' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by rp.startdate,rp.enddate) - sper ) prp where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='bec92b1d-4b99-4aad-ddcb-a693b929acd7' and id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-08-01') and date('2022-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and sr.daydate between date('2021-08-01') and date(date_trunc('week',date('2022-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days') - --where id_staff= '0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date('2021-08-01') and date('2022-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '6748aadc-7171-bc73-a0b3-e097b8fa8716') - where pd.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and pd.daydate between date('2021-08-01') and date('2022-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '0bfc88e6-76fe-24a7-78b9-adbdff787413' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'0bfc88e6-76fe-24a7-78b9-adbdff787413' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'0bfc88e6-76fe-24a7-78b9-adbdff787413' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by rp.startdate,rp.enddate) - sper ) prp where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='6748aadc-7171-bc73-a0b3-e097b8fa8716' and id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-02-01') and date('2022-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and sr.daydate between date('2022-02-01') and date(date_trunc('week',date('2022-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days') - --where id_staff= '0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date('2022-02-01') and date('2022-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8') - where pd.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and pd.daydate between date('2022-02-01') and date('2022-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '0bfc88e6-76fe-24a7-78b9-adbdff787413' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'0bfc88e6-76fe-24a7-78b9-adbdff787413' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'0bfc88e6-76fe-24a7-78b9-adbdff787413' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by rp.startdate,rp.enddate) - sper ) prp where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' and id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-08-01') and date('2023-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and sr.daydate between date('2022-08-01') and date(date_trunc('week',date('2023-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days') - --where id_staff= '0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date('2022-08-01') and date('2023-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd6b04e48-367a-6b0b-0aa2-d8f956df55e2') - where pd.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and pd.daydate between date('2022-08-01') and date('2023-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '0bfc88e6-76fe-24a7-78b9-adbdff787413' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id from lousdiner.reportperiod order by startdate,enddate; -QUERYARRAY: select id,startdate,enddate from lousdiner.reportperiod where -startdate >= date((select min(startdate) from lousdiner.staffcontract where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b')) -or date((select min(startdate) from lousdiner.staffcontract where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b')) between startdate and enddate order by startdate,enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-04-14'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-04-12'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and (daydate > date('2023-02-05') or daydate < date('2021-04-12')) - OR (id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' AND daydate not between date('2021-04-12') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('bec92b1d-4b99-4aad-ddcb-a693b929acd7','ef90b898-96ad-f5f1-b0b9-ad9a4d95320b') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-04-14'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-04-12'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and (daydate > date('2023-02-05') or daydate < date('2021-04-12')) - OR (id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' AND daydate not between date('2021-04-12') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('6748aadc-7171-bc73-a0b3-e097b8fa8716','ef90b898-96ad-f5f1-b0b9-ad9a4d95320b') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-04-14'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-04-12'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and (daydate > date('2023-02-05') or daydate < date('2021-04-12')) - OR (id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' AND daydate not between date('2021-04-12') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8','ef90b898-96ad-f5f1-b0b9-ad9a4d95320b') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-04-14'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-04-12'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and (daydate > date('2023-02-05') or daydate < date('2021-04-12')) - OR (id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' AND daydate not between date('2021-04-12') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('d6b04e48-367a-6b0b-0aa2-d8f956df55e2','ef90b898-96ad-f5f1-b0b9-ad9a4d95320b') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select reportperiodunit,reportperiodlength from public.companies where schemata='lousdiner' -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ) scx where startdate < enddate and id='bec92b1d-4b99-4aad-ddcb-a693b929acd7' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-04-14'),date('2021-07-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 78 as maxdays,78 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date('2021-02-01') and date('2021-07-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-07-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-07-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=78,contracthours='624:00:00' where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by rp.startdate,rp.enddate) - sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-02-01') and date('2021-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days') - --where id_staff= 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date('2021-02-01') and date('2021-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7') - where pd.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and pd.daydate between date('2021-02-01') and date('2021-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ) scx where startdate < enddate and id='6748aadc-7171-bc73-a0b3-e097b8fa8716' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-08-01'),date('2022-01-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 131 as maxdays,131 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date('2021-08-01') and date('2022-01-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2022-01-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2022-01-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=131,contracthours='1048:00:00' where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select * from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by rp.startdate,rp.enddate) - sper ) prp where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='bec92b1d-4b99-4aad-ddcb-a693b929acd7' and id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-08-01') and date('2022-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and sr.daydate between date('2021-08-01') and date(date_trunc('week',date('2022-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days') - --where id_staff= 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date('2021-08-01') and date('2022-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '6748aadc-7171-bc73-a0b3-e097b8fa8716') - where pd.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and pd.daydate between date('2021-08-01') and date('2022-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ) scx where startdate < enddate and id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2022-02-01'),date('2022-07-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 129 as maxdays,129 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date('2022-02-01') and date('2022-07-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2022-07-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2022-07-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=129,contracthours='1032:00:00' where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select * from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by rp.startdate,rp.enddate) - sper ) prp where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='6748aadc-7171-bc73-a0b3-e097b8fa8716' and id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-02-01') and date('2022-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and sr.daydate between date('2022-02-01') and date(date_trunc('week',date('2022-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days') - --where id_staff= 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date('2022-02-01') and date('2022-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8') - where pd.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and pd.daydate between date('2022-02-01') and date('2022-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ) scx where startdate < enddate and id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2022-08-01'),date('2023-01-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 132 as maxdays,132 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date('2022-08-01') and date('2023-01-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2023-01-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2023-01-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=132,contracthours='1056:00:00' where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select * from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by rp.startdate,rp.enddate) - sper ) prp where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' and id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-08-01') and date('2023-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and sr.daydate between date('2022-08-01') and date(date_trunc('week',date('2023-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days') - --where id_staff= 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date('2022-08-01') and date('2023-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd6b04e48-367a-6b0b-0aa2-d8f956df55e2') - where pd.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and pd.daydate between date('2022-08-01') and date('2023-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -EXEC: insert into lousdiner.staffvacancyyear (id_staff,vacyear) - select id_staff,to_char(daydate,'YYYY')::int4 as vyear from lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' group by id_staff,vyear order by id_staff,vyear - on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-04-14'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-04-12'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and (daydate > date('2023-02-05') or daydate < date('2021-04-12')) - OR (id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' AND daydate not between date('2021-04-12') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by rp.startdate,rp.enddate) - sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-02-01') and date('2021-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days') - --where id_staff= 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date('2021-02-01') and date('2021-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7') - where pd.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and pd.daydate between date('2021-02-01') and date('2021-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-04-14'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-04-12'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and (daydate > date('2023-02-05') or daydate < date('2021-04-12')) - OR (id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' AND daydate not between date('2021-04-12') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by rp.startdate,rp.enddate) - sper ) prp where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='bec92b1d-4b99-4aad-ddcb-a693b929acd7' and id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-08-01') and date('2022-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and sr.daydate between date('2021-08-01') and date(date_trunc('week',date('2022-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days') - --where id_staff= 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date('2021-08-01') and date('2022-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '6748aadc-7171-bc73-a0b3-e097b8fa8716') - where pd.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and pd.daydate between date('2021-08-01') and date('2022-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-04-14'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-04-12'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and (daydate > date('2023-02-05') or daydate < date('2021-04-12')) - OR (id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' AND daydate not between date('2021-04-12') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by rp.startdate,rp.enddate) - sper ) prp where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='6748aadc-7171-bc73-a0b3-e097b8fa8716' and id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-02-01') and date('2022-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and sr.daydate between date('2022-02-01') and date(date_trunc('week',date('2022-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days') - --where id_staff= 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date('2022-02-01') and date('2022-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8') - where pd.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and pd.daydate between date('2022-02-01') and date('2022-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-04-14'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-04-12'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and (daydate > date('2023-02-05') or daydate < date('2021-04-12')) - OR (id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' AND daydate not between date('2021-04-12') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by rp.startdate,rp.enddate) - sper ) prp where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' and id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-08-01') and date('2023-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and sr.daydate between date('2022-08-01') and date(date_trunc('week',date('2023-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days') - --where id_staff= 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date('2022-08-01') and date('2023-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::time)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd6b04e48-367a-6b0b-0aa2-d8f956df55e2') - where pd.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and pd.daydate between date('2022-08-01') and date('2023-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = '6748aadc-7171-bc73-a0b3-e097b8fa8716' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = '0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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.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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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 lousdiner.staffgroups sg LEFT JOIN lousdiner.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 lousdiner.timetrackerconfig order by trackername -QUERYARRAY: select ttr.*, st.* ,stg.groupname,'' || COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' AS staffname,sc.staffstatus from lousdiner.staff st -LEFT JOIN lousdiner.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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from lousdiner.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='lousdiner') 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 lousdiner.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from lousdiner.staff where id='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from lousdiner.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from lousdiner.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join lousdiner.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - join lousdiner.staff st on (pd.id_staff=st.id) - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from lousdiner.staffreportperioddays spd - join lousdiner.staff st on (st.id=spd.id_staff) - join lousdiner.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from lousdiner.staffvacancyyear where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' 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 lousdiner.staffcontract where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from lousdiner.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from lousdiner.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join lousdiner.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - join lousdiner.staff st on (pd.id_staff=st.id) - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from lousdiner.staff where id='0bfc88e6-76fe-24a7-78b9-adbdff787413' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from lousdiner.staffcontract where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by startdate,enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from lousdiner.staffreportperioddays spd - join lousdiner.staff st on (st.id=spd.id_staff) - join lousdiner.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '0bfc88e6-76fe-24a7-78b9-adbdff787413' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from lousdiner.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from lousdiner.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join lousdiner.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - join lousdiner.staff st on (pd.id_staff=st.id) - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '0bfc88e6-76fe-24a7-78b9-adbdff787413' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from lousdiner.staffvacancyyear where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by vacyear; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from lousdiner.staff where id='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from lousdiner.staff where id='ae108794-eb2b-836d-7348-50f30bea5204' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from lousdiner.staffcontract where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by startdate,enddate; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ae108794-eb2b-836d-7348-50f30bea5204' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from lousdiner.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from lousdiner.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join lousdiner.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - join lousdiner.staff st on (pd.id_staff=st.id) - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ae108794-eb2b-836d-7348-50f30bea5204' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from lousdiner.staffreportperioddays spd - join lousdiner.staff st on (st.id=spd.id_staff) - join lousdiner.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from lousdiner.staffcontract where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ae108794-eb2b-836d-7348-50f30bea5204' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from lousdiner.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from lousdiner.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join lousdiner.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - join lousdiner.staff st on (pd.id_staff=st.id) - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ae108794-eb2b-836d-7348-50f30bea5204' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from lousdiner.staffreportperioddays spd - join lousdiner.staff st on (st.id=spd.id_staff) - join lousdiner.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from lousdiner.staffvacancyyear where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by vacyear; -QUERY: select * from lousdiner.staff where id='d439cd6a-7758-2072-9c4b-eca7639bd94f' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'd439cd6a-7758-2072-9c4b-eca7639bd94f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by startdate,enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from lousdiner.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from lousdiner.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join lousdiner.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - join lousdiner.staff st on (pd.id_staff=st.id) - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'd439cd6a-7758-2072-9c4b-eca7639bd94f' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from lousdiner.staffvacancyyear where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by vacyear; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from lousdiner.staffreportperioddays spd - join lousdiner.staff st on (st.id=spd.id_staff) - join lousdiner.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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.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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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 lousdiner.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 lousdiner.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = '6748aadc-7171-bc73-a0b3-e097b8fa8716' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = 'd6b04e48-367a-6b0b-0aa2-d8f956df55e2' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = '0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = '6748aadc-7171-bc73-a0b3-e097b8fa8716' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7' -QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff - ,to_char(ws.workhours::interval,'HH24:MI') as workhours - ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal - ,to_char(ws.vacillhours,'HH24:MI') as vacancyill - ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra - ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours - ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours - ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours - ,to_char(ws.totalhours,'HH24:MI') as totalhours - ,cd.contractworkdays - ,cd.cmpcontractdays - ,cd.cmpweekhours - ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours - ,ws.periodworkhours - ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff - ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours - ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff - ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours - ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours - ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours - ,case when cd.contractworkdays < cd.cmpcontractdays then - to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI') - else - to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI') - end as maxweekhours - ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else - to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI') - end as defaultweekhours - from ( - SELECT weekstart,weekend,calweek,calyear, id_staff, - sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours, - sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours, - --sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause, - sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours, - sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours, - sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours, - sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours, - sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours, - sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours, - sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours, - sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays, - sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date('2021-02-01') and date('2021-08-01') - ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff - ORDER BY weekstart) ws left join ( - select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours, - case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays, - case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays - from ( select id_staff,weekdays ,weekhours, - case when startdate> date('2021-02-01') then startdate else date('2021-02-01') end as staffperiodstart, - case when enddate is null or enddate > date('2021-08-01') then date('2021-08-01') - else enddate end as staffperiodend from lousdiner.staffcontract where id_staff='45270017-c671-2912-5dde-6febfabb2668' - and startdate < date('2021-08-01') - ) sc - join lousdiner.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend) - group by date(date_trunc('week',pd.daydate)),pd.id_staff - ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart - left join ( - select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from ( - select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate, - case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours , - case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours - from lousdiner.staffreportperioddays lpd - left join lousdiner.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate) - cross join (select * from lousdiner.worktimes where isdefault=true) wkdef - where id_staff='45270017-c671-2912-5dde-6febfabb2668' and lpd.daydate between date('2021-02-01') and date('2021-08-01') - order by lpd.daydate ) mh group by id_staff,weekstart - ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart - left join ( - select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from ( - select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from ( -select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from lousdiner.timetracker -where daydate between date('2021-02-01') and date('2021-07-31') and id_staff ='45270017-c671-2912-5dde-6febfabb2668') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff - ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment, - vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment, - date(date_trunc('week',pd.daydate)) as weekstart, - to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1, - to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1, - to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2, - to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2, - to_char(pd.timepause::interval, 'HH24:MI') AS timepause, - -- coalesce('
' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '
','') AS dspvacancyhours, - to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours, - to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours, - to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours, - to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours, - to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours, - to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours, - to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours, - to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours, - to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours, - to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours, - to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours, - to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1, - to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1, - to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2, - to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2, - COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata, - COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata, - CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter, - to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours, - to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours, - to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation, - to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours, - max(vd.vacancyname) as vacancyname, - to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime, - interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff, - max(tt.incompletetrack) as incompletetrack - FROM lousdiner.staffreportperioddays pd - JOIN lousdiner.staff st ON pd.id_staff = st.id and st.id='45270017-c671-2912-5dde-6febfabb2668' and st.isdeleted is null - LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto, - yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval, - date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate - left join lousdiner.worktimes wk on pd.daydate between wk.startdate and wk.enddate - cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from lousdiner.worktimes where isdefault =true) wkstd - left join lousdiner.vacancydays vd on pd.daydate=vd.daydate - left join ( - select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime, - sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack -from lousdiner.timetracker where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date('2021-02-01') and date('2021-08-01') group by daydate - ) tt on pd.daydate=tt.daydate - WHERE pd.daydate between date('2021-02-01') and date('2021-08-01') - group by pd.id - ORDER BY pd.id_staff, pd.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7' -QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from lousdiner.staffreportperioddays where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate < date('2021-02-02') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1; -QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from lousdiner.staffreportperioddays where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate > date('2021-02-02') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1; -dhours - ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours - ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours - ,to_char(ws.totalhours,'HH24:MI') as totalhours - ,cd.contractworkdays - ,cd.cmpcontractdays - ,cd.cmpweekhours - ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours - ,ws.periodworkhours - ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff - ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours - ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff - ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours - ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours - ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours - ,case when cd.contractworkdays < cd.cmpcontractdays then - to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI') - else - to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI') - end as maxweekhours - ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else - to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI') - end as defaultweekhours - from ( - SELECT weekstart,weekend,calweek,calyear, id_staff, - sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours, - sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours, - --sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause, - sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours, - sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours, - sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours, - sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours, - sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours, - sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours, - sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours, - sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays, - sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date('2021-02-01') and date('2021-08-01') - ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff - ORDER BY weekstart) ws left join ( - select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours, - case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays, - case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays - from ( select id_staff,weekdays ,weekhours, - case when startdate> date('2021-02-01') then startdate else date('2021-02-01') end as staffperiodstart, - case when enddate is null or enddate > date('2021-08-01') then date('2021-08-01') - else enddate end as staffperiodend from lousdiner.staffcontract where id_staff='45270017-c671-2912-5dde-6febfabb2668' - and startdate < date('2021-08-01') - ) sc - join lousdiner.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend) - group by date(date_trunc('week',pd.daydate)),pd.id_staff - ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart - left join ( - select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from ( - select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate, - case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours , - case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours - from lousdiner.staffreportperioddays lpd - left join lousdiner.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate) - cross join (select * from lousdiner.worktimes where isdefault=true) wkdef - where id_staff='45270017-c671-2912-5dde-6febfabb2668' and lpd.daydate between date('2021-02-01') and date('2021-08-01') - order by lpd.daydate ) mh group by id_staff,weekstart - ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart - left join ( - select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from ( - select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from ( -select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from lousdiner.timetracker -where daydate between date('2021-02-01') and date('2021-07-31') and id_staff ='45270017-c671-2912-5dde-6febfabb2668') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff - ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff; -QUERY: select weekhours from lousdiner.staffcontract where id_staff='45270017-c671-2912-5dde-6febfabb2668' and ((date('2021-02-02') between startdate and enddate) or (startdate <= date('2021-02-02') and enddate is null)) order by startdate,enddate nulls first limit 1; -QUERY: select to_char(wk.maxdayhours,'HH24:MI') as maxdayhours, - to_char(wk.maxweekhours,'HH24:MI') as maxweekhours, - to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours, - to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation, - to_char(wk.defaultweekhours,'HH24:MI') as defaultweekhours, - '' as datebefore, - '' as timebefore, - '2021-02-03' as dateafter, - '10:00' as timeafter - from lousdiner.worktimes wk where (date('2021-02-02') between wk.startdate and wk.enddate) or (wk.startdate is null and wk.enddate is null) and maxhourspercents is null - order by wk.startdate,wk.enddate nulls last limit 1; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment, - vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment, - date(date_trunc('week',pd.daydate)) as weekstart, - to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1, - to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1, - to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2, - to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2, - to_char(pd.timepause::interval, 'HH24:MI') AS timepause, - -- coalesce('
' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '
','') AS dspvacancyhours, - to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours, - to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours, - to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours, - to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours, - to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours, - to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours, - to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours, - to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours, - to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours, - to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours, - to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours, - to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1, - to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1, - to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2, - to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2, - COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata, - COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata, - CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter, - to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours, - to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours, - to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation, - to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours, - max(vd.vacancyname) as vacancyname, - to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime, - interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff, - max(tt.incompletetrack) as incompletetrack - FROM lousdiner.staffreportperioddays pd - JOIN lousdiner.staff st ON pd.id_staff = st.id and st.id='45270017-c671-2912-5dde-6febfabb2668' and st.isdeleted is null - LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto, - yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval, - date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate - left join lousdiner.worktimes wk on pd.daydate between wk.startdate and wk.enddate - cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from lousdiner.worktimes where isdefault =true) wkstd - left join lousdiner.vacancydays vd on pd.daydate=vd.daydate - left join ( - select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime, - sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack -from lousdiner.timetracker where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date('2021-02-01') and date('2021-08-01') group by daydate - ) tt on pd.daydate=tt.daydate - WHERE pd.daydate between date('2021-02-01') and date('2021-08-01') - group by pd.id - ORDER BY pd.id_staff, pd.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='45270017-c671-2912-5dde-6febfabb2668' order by stamp_in,stamp_out; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-02') and id_staff='45270017-c671-2912-5dde-6febfabb2668' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, '45270017-c671-2912-5dde-6febfabb2668' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -QUERYARRAY: select public.getuuid() as id, '45270017-c671-2912-5dde-6febfabb2668' as id_staff,date('2021-02-02') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -EXEC: UPDATE lousdiner.staffreportperioddays SET timestart1='10:00',timeend1='14:00',timestart2='17:00',timeend2='21:30',pausestart1=null,pauseend1=null,pausestart2='21:00',pauseend2='21:30',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='1d3d9719-f56a-14cd-b197-0bdb4e5f65de'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='45270017-c671-2912-5dde-6febfabb2668' order by rp.startdate,rp.enddate) - sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-02-01') and date('2021-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='45270017-c671-2912-5dde-6febfabb2668' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='45270017-c671-2912-5dde-6febfabb2668' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days') - --where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date('2021-02-01') and date('2021-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-07-26'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7') - where pd.id_staff='45270017-c671-2912-5dde-6febfabb2668' and pd.daydate between date('2021-02-01') and date('2021-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '45270017-c671-2912-5dde-6febfabb2668' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7' -QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff - ,to_char(ws.workhours::interval,'HH24:MI') as workhours - ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal - ,to_char(ws.vacillhours,'HH24:MI') as vacancyill - ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra - ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours - ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours - ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours - ,to_char(ws.totalhours,'HH24:MI') as totalhours - ,cd.contractworkdays - ,cd.cmpcontractdays - ,cd.cmpweekhours - ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours - ,ws.periodworkhours - ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff - ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours - ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff - ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours - ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours - ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours - ,case when cd.contractworkdays < cd.cmpcontractdays then - to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI') - else - to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI') - end as maxweekhours - ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else - to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI') - end as defaultweekhours - from ( - SELECT weekstart,weekend,calweek,calyear, id_staff, - sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours, - sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours, - --sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause, - sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours, - sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours, - sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours, - sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours, - sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours, - sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours, - sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours, - sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays, - sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01') - ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff - ORDER BY weekstart) ws left join ( - select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours, - case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays, - case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays - from ( select id_staff,weekdays ,weekhours, - case when startdate> date('2021-02-01') then startdate else date('2021-02-01') end as staffperiodstart, - case when enddate is null or enddate > date('2021-08-01') then date('2021-08-01') - else enddate end as staffperiodend from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' - and startdate < date('2021-08-01') - ) sc - join lousdiner.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend) - group by date(date_trunc('week',pd.daydate)),pd.id_staff - ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart - left join ( - select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from ( - select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate, - case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours , - case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours - from lousdiner.staffreportperioddays lpd - left join lousdiner.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate) - cross join (select * from lousdiner.worktimes where isdefault=true) wkdef - where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and lpd.daydate between date('2021-02-01') and date('2021-08-01') - order by lpd.daydate ) mh group by id_staff,weekstart - ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart - left join ( - select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from ( - select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from ( -select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from lousdiner.timetracker -where daydate between date('2021-02-01') and date('2021-07-31') and id_staff ='d439cd6a-7758-2072-9c4b-eca7639bd94f') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff - ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment, - vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment, - date(date_trunc('week',pd.daydate)) as weekstart, - to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1, - to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1, - to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2, - to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2, - to_char(pd.timepause::interval, 'HH24:MI') AS timepause, - -- coalesce('
' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '
','') AS dspvacancyhours, - to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours, - to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours, - to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours, - to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours, - to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours, - to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours, - to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours, - to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours, - to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours, - to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours, - to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours, - to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1, - to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1, - to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2, - to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2, - COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata, - COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata, - CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter, - to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours, - to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours, - to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation, - to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours, - max(vd.vacancyname) as vacancyname, - to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime, - interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff, - max(tt.incompletetrack) as incompletetrack - FROM lousdiner.staffreportperioddays pd - JOIN lousdiner.staff st ON pd.id_staff = st.id and st.id='d439cd6a-7758-2072-9c4b-eca7639bd94f' and st.isdeleted is null - LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto, - yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval, - date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate - left join lousdiner.worktimes wk on pd.daydate between wk.startdate and wk.enddate - cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from lousdiner.worktimes where isdefault =true) wkstd - left join lousdiner.vacancydays vd on pd.daydate=vd.daydate - left join ( - select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime, - sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack -from lousdiner.timetracker where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01') group by daydate - ) tt on pd.daydate=tt.daydate - WHERE pd.daydate between date('2021-02-01') and date('2021-08-01') - group by pd.id - ORDER BY pd.id_staff, pd.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate < date('2021-02-03') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1; -QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7' -QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from lousdiner.staffreportperioddays where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate > date('2021-02-03') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1; -QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff - ,to_char(ws.workhours::interval,'HH24:MI') as workhours - ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal - ,to_char(ws.vacillhours,'HH24:MI') as vacancyill - ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra - ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours - ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours - ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours - ,to_char(ws.totalhours,'HH24:MI') as totalhours - ,cd.contractworkdays - ,cd.cmpcontractdays - ,cd.cmpweekhours - ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours - ,ws.periodworkhours - ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff - ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours - ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff - ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours - ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours - ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours - ,case when cd.contractworkdays < cd.cmpcontractdays then - to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI') - else - to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI') - end as maxweekhours - ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else - to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI') - end as defaultweekhours - from ( - SELECT weekstart,weekend,calweek,calyear, id_staff, - sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours, - sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours, - --sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause, - sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours, - sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours, - sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours, - sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours, - sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours, - sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours, - sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours, - sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays, - sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01') - ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff - ORDER BY weekstart) ws left join ( - select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours, - case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays, - case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays - from ( select id_staff,weekdays ,weekhours, - case when startdate> date('2021-02-01') then startdate else date('2021-02-01') end as staffperiodstart, - case when enddate is null or enddate > date('2021-08-01') then date('2021-08-01') - else enddate end as staffperiodend from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' - and startdate < date('2021-08-01') - ) sc - join lousdiner.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend) - group by date(date_trunc('week',pd.daydate)),pd.id_staff - ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart - left join ( - select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from ( - select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate, - case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours , - case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours - from lousdiner.staffreportperioddays lpd - left join lousdiner.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate) - cross join (select * from lousdiner.worktimes where isdefault=true) wkdef - where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and lpd.daydate between date('2021-02-01') and date('2021-08-01') - order by lpd.daydate ) mh group by id_staff,weekstart - ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart - left join ( - select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from ( - select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from ( -select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from lousdiner.timetracker -where daydate between date('2021-02-01') and date('2021-07-31') and id_staff ='d439cd6a-7758-2072-9c4b-eca7639bd94f') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff - ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff; -QUERY: select weekhours from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and ((date('2021-02-03') between startdate and enddate) or (startdate <= date('2021-02-03') and enddate is null)) order by startdate,enddate nulls first limit 1; -QUERY: select to_char(wk.maxdayhours,'HH24:MI') as maxdayhours, - to_char(wk.maxweekhours,'HH24:MI') as maxweekhours, - to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours, - to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation, - to_char(wk.defaultweekhours,'HH24:MI') as defaultweekhours, - '2021-02-02' as datebefore, - '21:30' as timebefore, - '2021-02-04' as dateafter, - '13:00' as timeafter - from lousdiner.worktimes wk where (date('2021-02-03') between wk.startdate and wk.enddate) or (wk.startdate is null and wk.enddate is null) and maxhourspercents is null - order by wk.startdate,wk.enddate nulls last limit 1; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment, - vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment, - date(date_trunc('week',pd.daydate)) as weekstart, - to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1, - to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1, - to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2, - to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2, - to_char(pd.timepause::interval, 'HH24:MI') AS timepause, - -- coalesce('
' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '
','') AS dspvacancyhours, - to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours, - to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours, - to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours, - to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours, - to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours, - to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours, - to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours, - to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours, - to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours, - to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours, - to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours, - to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1, - to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1, - to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2, - to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2, - COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata, - COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata, - CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter, - to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours, - to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours, - to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation, - to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours, - max(vd.vacancyname) as vacancyname, - to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime, - interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff, - max(tt.incompletetrack) as incompletetrack - FROM lousdiner.staffreportperioddays pd - JOIN lousdiner.staff st ON pd.id_staff = st.id and st.id='d439cd6a-7758-2072-9c4b-eca7639bd94f' and st.isdeleted is null - LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto, - yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval, - date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate - left join lousdiner.worktimes wk on pd.daydate between wk.startdate and wk.enddate - cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from lousdiner.worktimes where isdefault =true) wkstd - left join lousdiner.vacancydays vd on pd.daydate=vd.daydate - left join ( - select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime, - sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack -from lousdiner.timetracker where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-08-01') group by daydate - ) tt on pd.daydate=tt.daydate - WHERE pd.daydate between date('2021-02-01') and date('2021-08-01') - group by pd.id - ORDER BY pd.id_staff, pd.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-03') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-03') and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-03') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -QUERYARRAY: select public.getuuid() as id, 'd439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff,date('2021-02-03') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -EXEC: UPDATE lousdiner.staffreportperioddays SET timestart1='13:00',timeend1='21:30',timestart2=null,timeend2=null,pausestart1='21:00',pauseend1='21: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='fa29028f-0c85-670f-80e7-a64903367b39'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by rp.startdate,rp.enddate) - sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-02-01') and date('2021-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days') - --where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-07-26'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7') - where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and pd.daydate between date('2021-02-01') and date('2021-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'd439cd6a-7758-2072-9c4b-eca7639bd94f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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'; - || 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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,trackername from lousdiner.timetrackerconfig order by trackername -QUERYARRAY: select sg.id,sg.groupname,sg.groupcolor,sg.isdefault,COALESCE(count(st.id), 0) AS staffmembers FROM lousdiner.staffgroups sg LEFT JOIN lousdiner.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(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' AS staffname,sc.staffstatus from lousdiner.staff st -LEFT JOIN lousdiner.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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from lousdiner.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='lousdiner') 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 lousdiner.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: 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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,trackername from lousdiner.timetrackerconfig order by trackername -QUERYARRAY: select ttr.*, st.* ,stg.groupname,'' || COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' AS staffname,sc.staffstatus from lousdiner.staff st -LEFT JOIN lousdiner.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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from lousdiner.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='lousdiner') ttr -where st.isdeleted is null order by groupname,st.staffnumber,surname,prename; -QUERYARRAY: select sg.id,sg.groupname,sg.groupcolor,sg.isdefault,COALESCE(count(st.id), 0) AS staffmembers FROM lousdiner.staffgroups sg LEFT JOIN lousdiner.staff st ON (st.id_staffgroup = sg.id) WHERE st.isdeleted IS NULL GROUP BY sg.id ORDER BY sg.groupname; -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 lousdiner.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: 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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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 lousdiner.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 lousdiner.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = '6748aadc-7171-bc73-a0b3-e097b8fa8716' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id from lousdiner.staff where isdeleted is null; -QUERYARRAY: select id from lousdiner.reportperiod order by startdate,enddate; -QUERYARRAY: select id,startdate,enddate from lousdiner.reportperiod where -startdate >= date((select min(startdate) from lousdiner.staffcontract where id_staff='ae108794-eb2b-836d-7348-50f30bea5204')) -or date((select min(startdate) from lousdiner.staffcontract where id_staff='ae108794-eb2b-836d-7348-50f30bea5204')) between startdate and enddate order by startdate,enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='ae108794-eb2b-836d-7348-50f30bea5204' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('bec92b1d-4b99-4aad-ddcb-a693b929acd7','ae108794-eb2b-836d-7348-50f30bea5204') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='ae108794-eb2b-836d-7348-50f30bea5204' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('6748aadc-7171-bc73-a0b3-e097b8fa8716','ae108794-eb2b-836d-7348-50f30bea5204') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='ae108794-eb2b-836d-7348-50f30bea5204' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8','ae108794-eb2b-836d-7348-50f30bea5204') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='ae108794-eb2b-836d-7348-50f30bea5204' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('d6b04e48-367a-6b0b-0aa2-d8f956df55e2','ae108794-eb2b-836d-7348-50f30bea5204') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select reportperiodunit,reportperiodlength from public.companies where schemata='lousdiner' -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' - ) scx where startdate < enddate and id='bec92b1d-4b99-4aad-ddcb-a693b929acd7' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-02-01'),date('2021-07-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 130 as maxdays,130 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date('2021-02-01') and date('2021-07-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-07-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-07-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=130,contracthours='1040:00:00' where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by rp.startdate,rp.enddate) - sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-02-01') and date('2021-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days') - --where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date('2021-02-01') and date('2021-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7') - where pd.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and pd.daydate between date('2021-02-01') and date('2021-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ae108794-eb2b-836d-7348-50f30bea5204' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' - ) scx where startdate < enddate and id='6748aadc-7171-bc73-a0b3-e097b8fa8716' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-08-01'),date('2022-01-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 131 as maxdays,131 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date('2021-08-01') and date('2022-01-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2022-01-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2022-01-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=131,contracthours='1048:00:00' where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select * from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by rp.startdate,rp.enddate) - sper ) prp where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='bec92b1d-4b99-4aad-ddcb-a693b929acd7' and id_staff='ae108794-eb2b-836d-7348-50f30bea5204'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-08-01') and date('2022-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and sr.daydate between date('2021-08-01') and date(date_trunc('week',date('2022-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days') - --where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date('2021-08-01') and date('2022-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '6748aadc-7171-bc73-a0b3-e097b8fa8716') - where pd.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and pd.daydate between date('2021-08-01') and date('2022-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ae108794-eb2b-836d-7348-50f30bea5204' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' - ) scx where startdate < enddate and id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2022-02-01'),date('2022-07-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 129 as maxdays,129 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date('2022-02-01') and date('2022-07-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2022-07-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2022-07-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=129,contracthours='1032:00:00' where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select * from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by rp.startdate,rp.enddate) - sper ) prp where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='6748aadc-7171-bc73-a0b3-e097b8fa8716' and id_staff='ae108794-eb2b-836d-7348-50f30bea5204'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-02-01') and date('2022-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and sr.daydate between date('2022-02-01') and date(date_trunc('week',date('2022-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days') - --where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date('2022-02-01') and date('2022-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8') - where pd.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and pd.daydate between date('2022-02-01') and date('2022-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ae108794-eb2b-836d-7348-50f30bea5204' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' - ) scx where startdate < enddate and id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2022-08-01'),date('2023-01-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 132 as maxdays,132 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date('2022-08-01') and date('2023-01-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2023-01-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2023-01-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=132,contracthours='1056:00:00' where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select * from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by rp.startdate,rp.enddate) - sper ) prp where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' and id_staff='ae108794-eb2b-836d-7348-50f30bea5204'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-08-01') and date('2023-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and sr.daydate between date('2022-08-01') and date(date_trunc('week',date('2023-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days') - --where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date('2022-08-01') and date('2023-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd6b04e48-367a-6b0b-0aa2-d8f956df55e2') - where pd.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and pd.daydate between date('2022-08-01') and date('2023-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ae108794-eb2b-836d-7348-50f30bea5204' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -EXEC: insert into lousdiner.staffvacancyyear (id_staff,vacyear) - select id_staff,to_char(daydate,'YYYY')::int4 as vyear from lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' group by id_staff,vyear order by id_staff,vyear - on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='ae108794-eb2b-836d-7348-50f30bea5204' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by rp.startdate,rp.enddate) - sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-02-01') and date('2021-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days') - --where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date('2021-02-01') and date('2021-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7') - where pd.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and pd.daydate between date('2021-02-01') and date('2021-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ae108794-eb2b-836d-7348-50f30bea5204' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='ae108794-eb2b-836d-7348-50f30bea5204' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by rp.startdate,rp.enddate) - sper ) prp where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='bec92b1d-4b99-4aad-ddcb-a693b929acd7' and id_staff='ae108794-eb2b-836d-7348-50f30bea5204'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-08-01') and date('2022-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and sr.daydate between date('2021-08-01') and date(date_trunc('week',date('2022-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days') - --where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date('2021-08-01') and date('2022-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '6748aadc-7171-bc73-a0b3-e097b8fa8716') - where pd.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and pd.daydate between date('2021-08-01') and date('2022-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ae108794-eb2b-836d-7348-50f30bea5204' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='ae108794-eb2b-836d-7348-50f30bea5204' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by rp.startdate,rp.enddate) - sper ) prp where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='6748aadc-7171-bc73-a0b3-e097b8fa8716' and id_staff='ae108794-eb2b-836d-7348-50f30bea5204'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-02-01') and date('2022-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and sr.daydate between date('2022-02-01') and date(date_trunc('week',date('2022-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days') - --where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date('2022-02-01') and date('2022-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8') - where pd.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and pd.daydate between date('2022-02-01') and date('2022-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ae108794-eb2b-836d-7348-50f30bea5204' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='ae108794-eb2b-836d-7348-50f30bea5204' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by rp.startdate,rp.enddate) - sper ) prp where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' and id_staff='ae108794-eb2b-836d-7348-50f30bea5204'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-08-01') and date('2023-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and sr.daydate between date('2022-08-01') and date(date_trunc('week',date('2023-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days') - --where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date('2022-08-01') and date('2023-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd6b04e48-367a-6b0b-0aa2-d8f956df55e2') - where pd.id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and pd.daydate between date('2022-08-01') and date('2023-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ae108794-eb2b-836d-7348-50f30bea5204' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id from lousdiner.reportperiod order by startdate,enddate; -QUERYARRAY: select id,startdate,enddate from lousdiner.reportperiod where -startdate >= date((select min(startdate) from lousdiner.staffcontract where id_staff='45270017-c671-2912-5dde-6febfabb2668')) -or date((select min(startdate) from lousdiner.staffcontract where id_staff='45270017-c671-2912-5dde-6febfabb2668')) between startdate and enddate order by startdate,enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'45270017-c671-2912-5dde-6febfabb2668' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='45270017-c671-2912-5dde-6febfabb2668' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'45270017-c671-2912-5dde-6febfabb2668' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='45270017-c671-2912-5dde-6febfabb2668' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='45270017-c671-2912-5dde-6febfabb2668' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('bec92b1d-4b99-4aad-ddcb-a693b929acd7','45270017-c671-2912-5dde-6febfabb2668') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'45270017-c671-2912-5dde-6febfabb2668' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='45270017-c671-2912-5dde-6febfabb2668' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'45270017-c671-2912-5dde-6febfabb2668' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='45270017-c671-2912-5dde-6febfabb2668' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='45270017-c671-2912-5dde-6febfabb2668' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('6748aadc-7171-bc73-a0b3-e097b8fa8716','45270017-c671-2912-5dde-6febfabb2668') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'45270017-c671-2912-5dde-6febfabb2668' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='45270017-c671-2912-5dde-6febfabb2668' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'45270017-c671-2912-5dde-6febfabb2668' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='45270017-c671-2912-5dde-6febfabb2668' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='45270017-c671-2912-5dde-6febfabb2668' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8','45270017-c671-2912-5dde-6febfabb2668') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'45270017-c671-2912-5dde-6febfabb2668' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='45270017-c671-2912-5dde-6febfabb2668' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'45270017-c671-2912-5dde-6febfabb2668' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='45270017-c671-2912-5dde-6febfabb2668' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='45270017-c671-2912-5dde-6febfabb2668' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('d6b04e48-367a-6b0b-0aa2-d8f956df55e2','45270017-c671-2912-5dde-6febfabb2668') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select reportperiodunit,reportperiodlength from public.companies where schemata='lousdiner' -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='45270017-c671-2912-5dde-6febfabb2668' - ) scx where startdate < enddate and id='bec92b1d-4b99-4aad-ddcb-a693b929acd7' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-02-01'),date('2021-07-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 130 as maxdays,130 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date('2021-02-01') and date('2021-07-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-07-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-07-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='45270017-c671-2912-5dde-6febfabb2668' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=130,contracthours='1040:00:00' where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='45270017-c671-2912-5dde-6febfabb2668' order by rp.startdate,rp.enddate) - sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-02-01') and date('2021-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='45270017-c671-2912-5dde-6febfabb2668' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='45270017-c671-2912-5dde-6febfabb2668' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days') - --where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date('2021-02-01') and date('2021-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-07-26'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7') - where pd.id_staff='45270017-c671-2912-5dde-6febfabb2668' and pd.daydate between date('2021-02-01') and date('2021-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '45270017-c671-2912-5dde-6febfabb2668' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='45270017-c671-2912-5dde-6febfabb2668' - ) scx where startdate < enddate and id='6748aadc-7171-bc73-a0b3-e097b8fa8716' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-08-01'),date('2022-01-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 131 as maxdays,131 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date('2021-08-01') and date('2022-01-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2022-01-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2022-01-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='45270017-c671-2912-5dde-6febfabb2668' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=131,contracthours='1048:00:00' where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select * from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='45270017-c671-2912-5dde-6febfabb2668' order by rp.startdate,rp.enddate) - sper ) prp where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='bec92b1d-4b99-4aad-ddcb-a693b929acd7' and id_staff='45270017-c671-2912-5dde-6febfabb2668'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-08-01') and date('2022-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='45270017-c671-2912-5dde-6febfabb2668' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,1+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='45270017-c671-2912-5dde-6febfabb2668' and sr.daydate between date('2021-07-26') and date(date_trunc('week',date('2022-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days') - --where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date('2021-08-01') and date('2022-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2021-08-02'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '6748aadc-7171-bc73-a0b3-e097b8fa8716') - where pd.id_staff='45270017-c671-2912-5dde-6febfabb2668' and pd.daydate between date('2021-08-01') and date('2022-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '45270017-c671-2912-5dde-6febfabb2668' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='45270017-c671-2912-5dde-6febfabb2668' - ) scx where startdate < enddate and id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2022-02-01'),date('2022-07-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 129 as maxdays,129 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date('2022-02-01') and date('2022-07-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2022-07-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2022-07-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='45270017-c671-2912-5dde-6febfabb2668' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=129,contracthours='1032:00:00' where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select * from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='45270017-c671-2912-5dde-6febfabb2668' order by rp.startdate,rp.enddate) - sper ) prp where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='6748aadc-7171-bc73-a0b3-e097b8fa8716' and id_staff='45270017-c671-2912-5dde-6febfabb2668'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-02-01') and date('2022-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='45270017-c671-2912-5dde-6febfabb2668' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,2+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='45270017-c671-2912-5dde-6febfabb2668' and sr.daydate between date('2021-08-02') and date(date_trunc('week',date('2022-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days') - --where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date('2022-02-01') and date('2022-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8') - where pd.id_staff='45270017-c671-2912-5dde-6febfabb2668' and pd.daydate between date('2022-02-01') and date('2022-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '45270017-c671-2912-5dde-6febfabb2668' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='45270017-c671-2912-5dde-6febfabb2668' - ) scx where startdate < enddate and id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2022-08-01'),date('2023-01-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 132 as maxdays,132 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date('2022-08-01') and date('2023-01-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2023-01-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2023-01-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='45270017-c671-2912-5dde-6febfabb2668' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=132,contracthours='1056:00:00' where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select * from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='45270017-c671-2912-5dde-6febfabb2668' order by rp.startdate,rp.enddate) - sper ) prp where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' and id_staff='45270017-c671-2912-5dde-6febfabb2668'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-08-01') and date('2023-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='45270017-c671-2912-5dde-6febfabb2668' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='45270017-c671-2912-5dde-6febfabb2668' and sr.daydate between date('2022-08-01') and date(date_trunc('week',date('2023-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days') - --where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date('2022-08-01') and date('2023-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd6b04e48-367a-6b0b-0aa2-d8f956df55e2') - where pd.id_staff='45270017-c671-2912-5dde-6febfabb2668' and pd.daydate between date('2022-08-01') and date('2023-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '45270017-c671-2912-5dde-6febfabb2668' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -EXEC: insert into lousdiner.staffvacancyyear (id_staff,vacyear) - select id_staff,to_char(daydate,'YYYY')::int4 as vyear from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' group by id_staff,vyear order by id_staff,vyear - on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'45270017-c671-2912-5dde-6febfabb2668' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='45270017-c671-2912-5dde-6febfabb2668' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'45270017-c671-2912-5dde-6febfabb2668' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='45270017-c671-2912-5dde-6febfabb2668' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='45270017-c671-2912-5dde-6febfabb2668' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='45270017-c671-2912-5dde-6febfabb2668' order by rp.startdate,rp.enddate) - sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-02-01') and date('2021-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='45270017-c671-2912-5dde-6febfabb2668' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='45270017-c671-2912-5dde-6febfabb2668' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days') - --where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date('2021-02-01') and date('2021-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-07-26'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7') - where pd.id_staff='45270017-c671-2912-5dde-6febfabb2668' and pd.daydate between date('2021-02-01') and date('2021-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '45270017-c671-2912-5dde-6febfabb2668' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'45270017-c671-2912-5dde-6febfabb2668' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='45270017-c671-2912-5dde-6febfabb2668' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'45270017-c671-2912-5dde-6febfabb2668' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='45270017-c671-2912-5dde-6febfabb2668' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='45270017-c671-2912-5dde-6febfabb2668' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='45270017-c671-2912-5dde-6febfabb2668' order by rp.startdate,rp.enddate) - sper ) prp where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='bec92b1d-4b99-4aad-ddcb-a693b929acd7' and id_staff='45270017-c671-2912-5dde-6febfabb2668'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-08-01') and date('2022-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='45270017-c671-2912-5dde-6febfabb2668' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,1+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='45270017-c671-2912-5dde-6febfabb2668' and sr.daydate between date('2021-07-26') and date(date_trunc('week',date('2022-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days') - --where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date('2021-08-01') and date('2022-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2021-08-02'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '6748aadc-7171-bc73-a0b3-e097b8fa8716') - where pd.id_staff='45270017-c671-2912-5dde-6febfabb2668' and pd.daydate between date('2021-08-01') and date('2022-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '45270017-c671-2912-5dde-6febfabb2668' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'45270017-c671-2912-5dde-6febfabb2668' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='45270017-c671-2912-5dde-6febfabb2668' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'45270017-c671-2912-5dde-6febfabb2668' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='45270017-c671-2912-5dde-6febfabb2668' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='45270017-c671-2912-5dde-6febfabb2668' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='45270017-c671-2912-5dde-6febfabb2668' order by rp.startdate,rp.enddate) - sper ) prp where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='6748aadc-7171-bc73-a0b3-e097b8fa8716' and id_staff='45270017-c671-2912-5dde-6febfabb2668'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-02-01') and date('2022-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='45270017-c671-2912-5dde-6febfabb2668' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,2+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='45270017-c671-2912-5dde-6febfabb2668' and sr.daydate between date('2021-08-02') and date(date_trunc('week',date('2022-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days') - --where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date('2022-02-01') and date('2022-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8') - where pd.id_staff='45270017-c671-2912-5dde-6febfabb2668' and pd.daydate between date('2022-02-01') and date('2022-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '45270017-c671-2912-5dde-6febfabb2668' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'45270017-c671-2912-5dde-6febfabb2668' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='45270017-c671-2912-5dde-6febfabb2668' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'45270017-c671-2912-5dde-6febfabb2668' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='45270017-c671-2912-5dde-6febfabb2668' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='45270017-c671-2912-5dde-6febfabb2668' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='45270017-c671-2912-5dde-6febfabb2668' order by rp.startdate,rp.enddate) - sper ) prp where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' and id_staff='45270017-c671-2912-5dde-6febfabb2668'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-08-01') and date('2023-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='45270017-c671-2912-5dde-6febfabb2668' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='45270017-c671-2912-5dde-6febfabb2668' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='45270017-c671-2912-5dde-6febfabb2668' and sr.daydate between date('2022-08-01') and date(date_trunc('week',date('2023-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days') - --where id_staff= '45270017-c671-2912-5dde-6febfabb2668' and daydate between date('2022-08-01') and date('2023-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd6b04e48-367a-6b0b-0aa2-d8f956df55e2') - where pd.id_staff='45270017-c671-2912-5dde-6febfabb2668' and pd.daydate between date('2022-08-01') and date('2023-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '45270017-c671-2912-5dde-6febfabb2668' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id from lousdiner.reportperiod order by startdate,enddate; -QUERYARRAY: select id,startdate,enddate from lousdiner.reportperiod where -startdate >= date((select min(startdate) from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f')) -or date((select min(startdate) from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f')) between startdate and enddate order by startdate,enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('bec92b1d-4b99-4aad-ddcb-a693b929acd7','d439cd6a-7758-2072-9c4b-eca7639bd94f') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('6748aadc-7171-bc73-a0b3-e097b8fa8716','d439cd6a-7758-2072-9c4b-eca7639bd94f') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8','d439cd6a-7758-2072-9c4b-eca7639bd94f') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('d6b04e48-367a-6b0b-0aa2-d8f956df55e2','d439cd6a-7758-2072-9c4b-eca7639bd94f') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select reportperiodunit,reportperiodlength from public.companies where schemata='lousdiner' -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' - ) scx where startdate < enddate and id='bec92b1d-4b99-4aad-ddcb-a693b929acd7' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-02-01'),date('2021-07-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 130 as maxdays,130 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-07-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-07-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-07-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=130,contracthours='1040:00:00' where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by rp.startdate,rp.enddate) - sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-02-01') and date('2021-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days') - --where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-07-26'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7') - where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and pd.daydate between date('2021-02-01') and date('2021-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'd439cd6a-7758-2072-9c4b-eca7639bd94f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' - ) scx where startdate < enddate and id='6748aadc-7171-bc73-a0b3-e097b8fa8716' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-08-01'),date('2022-01-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 131 as maxdays,131 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-08-01') and date('2022-01-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2022-01-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2022-01-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=131,contracthours='1048:00:00' where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select * from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by rp.startdate,rp.enddate) - sper ) prp where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='bec92b1d-4b99-4aad-ddcb-a693b929acd7' and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-08-01') and date('2022-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,1+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and sr.daydate between date('2021-07-26') and date(date_trunc('week',date('2022-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days') - --where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-08-01') and date('2022-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2021-08-02'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '6748aadc-7171-bc73-a0b3-e097b8fa8716') - where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and pd.daydate between date('2021-08-01') and date('2022-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'd439cd6a-7758-2072-9c4b-eca7639bd94f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' - ) scx where startdate < enddate and id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2022-02-01'),date('2022-07-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 129 as maxdays,129 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2022-02-01') and date('2022-07-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2022-07-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2022-07-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=129,contracthours='1032:00:00' where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select * from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by rp.startdate,rp.enddate) - sper ) prp where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='6748aadc-7171-bc73-a0b3-e097b8fa8716' and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-02-01') and date('2022-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,2+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and sr.daydate between date('2021-08-02') and date(date_trunc('week',date('2022-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days') - --where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2022-02-01') and date('2022-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8') - where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and pd.daydate between date('2022-02-01') and date('2022-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'd439cd6a-7758-2072-9c4b-eca7639bd94f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' - ) scx where startdate < enddate and id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2022-08-01'),date('2023-01-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 132 as maxdays,132 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2022-08-01') and date('2023-01-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2023-01-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2023-01-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=132,contracthours='1056:00:00' where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select * from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by rp.startdate,rp.enddate) - sper ) prp where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-08-01') and date('2023-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and sr.daydate between date('2022-08-01') and date(date_trunc('week',date('2023-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days') - --where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2022-08-01') and date('2023-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd6b04e48-367a-6b0b-0aa2-d8f956df55e2') - where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and pd.daydate between date('2022-08-01') and date('2023-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'd439cd6a-7758-2072-9c4b-eca7639bd94f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -EXEC: insert into lousdiner.staffvacancyyear (id_staff,vacyear) - select id_staff,to_char(daydate,'YYYY')::int4 as vyear from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' group by id_staff,vyear order by id_staff,vyear - on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by rp.startdate,rp.enddate) - sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-02-01') and date('2021-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days') - --where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-02-01') and date('2021-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-07-26'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7') - where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and pd.daydate between date('2021-02-01') and date('2021-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'd439cd6a-7758-2072-9c4b-eca7639bd94f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by rp.startdate,rp.enddate) - sper ) prp where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='bec92b1d-4b99-4aad-ddcb-a693b929acd7' and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-08-01') and date('2022-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,1+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and sr.daydate between date('2021-07-26') and date(date_trunc('week',date('2022-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days') - --where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2021-08-01') and date('2022-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2021-08-02'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '6748aadc-7171-bc73-a0b3-e097b8fa8716') - where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and pd.daydate between date('2021-08-01') and date('2022-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'd439cd6a-7758-2072-9c4b-eca7639bd94f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by rp.startdate,rp.enddate) - sper ) prp where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='6748aadc-7171-bc73-a0b3-e097b8fa8716' and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-02-01') and date('2022-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,2+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and sr.daydate between date('2021-08-02') and date(date_trunc('week',date('2022-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days') - --where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2022-02-01') and date('2022-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8') - where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and pd.daydate between date('2022-02-01') and date('2022-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'd439cd6a-7758-2072-9c4b-eca7639bd94f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d439cd6a-7758-2072-9c4b-eca7639bd94f' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by rp.startdate,rp.enddate) - sper ) prp where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-08-01') and date('2023-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and sr.daydate between date('2022-08-01') and date(date_trunc('week',date('2023-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days') - --where id_staff= 'd439cd6a-7758-2072-9c4b-eca7639bd94f' and daydate between date('2022-08-01') and date('2023-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd6b04e48-367a-6b0b-0aa2-d8f956df55e2') - where pd.id_staff='d439cd6a-7758-2072-9c4b-eca7639bd94f' and pd.daydate between date('2022-08-01') and date('2023-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'd439cd6a-7758-2072-9c4b-eca7639bd94f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id from lousdiner.reportperiod order by startdate,enddate; -QUERYARRAY: select id,startdate,enddate from lousdiner.reportperiod where -startdate >= date((select min(startdate) from lousdiner.staffcontract where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413')) -or date((select min(startdate) from lousdiner.staffcontract where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413')) between startdate and enddate order by startdate,enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'0bfc88e6-76fe-24a7-78b9-adbdff787413' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'0bfc88e6-76fe-24a7-78b9-adbdff787413' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('bec92b1d-4b99-4aad-ddcb-a693b929acd7','0bfc88e6-76fe-24a7-78b9-adbdff787413') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'0bfc88e6-76fe-24a7-78b9-adbdff787413' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'0bfc88e6-76fe-24a7-78b9-adbdff787413' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('6748aadc-7171-bc73-a0b3-e097b8fa8716','0bfc88e6-76fe-24a7-78b9-adbdff787413') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'0bfc88e6-76fe-24a7-78b9-adbdff787413' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'0bfc88e6-76fe-24a7-78b9-adbdff787413' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8','0bfc88e6-76fe-24a7-78b9-adbdff787413') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'0bfc88e6-76fe-24a7-78b9-adbdff787413' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'0bfc88e6-76fe-24a7-78b9-adbdff787413' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('d6b04e48-367a-6b0b-0aa2-d8f956df55e2','0bfc88e6-76fe-24a7-78b9-adbdff787413') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select reportperiodunit,reportperiodlength from public.companies where schemata='lousdiner' -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' - ) scx where startdate < enddate and id='bec92b1d-4b99-4aad-ddcb-a693b929acd7' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-02-01'),date('2021-07-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 130 as maxdays,130 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date('2021-02-01') and date('2021-07-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-07-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-07-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=130,contracthours='1040:00:00' where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by rp.startdate,rp.enddate) - sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-02-01') and date('2021-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days') - --where id_staff= '0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date('2021-02-01') and date('2021-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7') - where pd.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and pd.daydate between date('2021-02-01') and date('2021-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '0bfc88e6-76fe-24a7-78b9-adbdff787413' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' - ) scx where startdate < enddate and id='6748aadc-7171-bc73-a0b3-e097b8fa8716' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-08-01'),date('2022-01-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 131 as maxdays,131 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date('2021-08-01') and date('2022-01-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2022-01-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2022-01-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=131,contracthours='1048:00:00' where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select * from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by rp.startdate,rp.enddate) - sper ) prp where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='bec92b1d-4b99-4aad-ddcb-a693b929acd7' and id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-08-01') and date('2022-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and sr.daydate between date('2021-08-01') and date(date_trunc('week',date('2022-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days') - --where id_staff= '0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date('2021-08-01') and date('2022-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '6748aadc-7171-bc73-a0b3-e097b8fa8716') - where pd.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and pd.daydate between date('2021-08-01') and date('2022-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '0bfc88e6-76fe-24a7-78b9-adbdff787413' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' - ) scx where startdate < enddate and id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2022-02-01'),date('2022-07-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 129 as maxdays,129 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date('2022-02-01') and date('2022-07-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2022-07-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2022-07-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=129,contracthours='1032:00:00' where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select * from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by rp.startdate,rp.enddate) - sper ) prp where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='6748aadc-7171-bc73-a0b3-e097b8fa8716' and id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-02-01') and date('2022-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and sr.daydate between date('2022-02-01') and date(date_trunc('week',date('2022-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days') - --where id_staff= '0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date('2022-02-01') and date('2022-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8') - where pd.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and pd.daydate between date('2022-02-01') and date('2022-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '0bfc88e6-76fe-24a7-78b9-adbdff787413' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' - ) scx where startdate < enddate and id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2022-08-01'),date('2023-01-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 132 as maxdays,132 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date('2022-08-01') and date('2023-01-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2023-01-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2023-01-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=132,contracthours='1056:00:00' where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select * from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by rp.startdate,rp.enddate) - sper ) prp where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' and id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-08-01') and date('2023-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and sr.daydate between date('2022-08-01') and date(date_trunc('week',date('2023-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days') - --where id_staff= '0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date('2022-08-01') and date('2023-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd6b04e48-367a-6b0b-0aa2-d8f956df55e2') - where pd.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and pd.daydate between date('2022-08-01') and date('2023-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '0bfc88e6-76fe-24a7-78b9-adbdff787413' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -EXEC: insert into lousdiner.staffvacancyyear (id_staff,vacyear) - select id_staff,to_char(daydate,'YYYY')::int4 as vyear from lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' group by id_staff,vyear order by id_staff,vyear - on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'0bfc88e6-76fe-24a7-78b9-adbdff787413' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'0bfc88e6-76fe-24a7-78b9-adbdff787413' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by rp.startdate,rp.enddate) - sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-02-01') and date('2021-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days') - --where id_staff= '0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date('2021-02-01') and date('2021-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7') - where pd.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and pd.daydate between date('2021-02-01') and date('2021-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '0bfc88e6-76fe-24a7-78b9-adbdff787413' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'0bfc88e6-76fe-24a7-78b9-adbdff787413' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'0bfc88e6-76fe-24a7-78b9-adbdff787413' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by rp.startdate,rp.enddate) - sper ) prp where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='bec92b1d-4b99-4aad-ddcb-a693b929acd7' and id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-08-01') and date('2022-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and sr.daydate between date('2021-08-01') and date(date_trunc('week',date('2022-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days') - --where id_staff= '0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date('2021-08-01') and date('2022-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '6748aadc-7171-bc73-a0b3-e097b8fa8716') - where pd.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and pd.daydate between date('2021-08-01') and date('2022-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '0bfc88e6-76fe-24a7-78b9-adbdff787413' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'0bfc88e6-76fe-24a7-78b9-adbdff787413' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'0bfc88e6-76fe-24a7-78b9-adbdff787413' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by rp.startdate,rp.enddate) - sper ) prp where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='6748aadc-7171-bc73-a0b3-e097b8fa8716' and id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-02-01') and date('2022-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and sr.daydate between date('2022-02-01') and date(date_trunc('week',date('2022-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days') - --where id_staff= '0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date('2022-02-01') and date('2022-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8') - where pd.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and pd.daydate between date('2022-02-01') and date('2022-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '0bfc88e6-76fe-24a7-78b9-adbdff787413' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'0bfc88e6-76fe-24a7-78b9-adbdff787413' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-02-01'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'0bfc88e6-76fe-24a7-78b9-adbdff787413' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-02-01'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and (daydate > date('2023-02-05') or daydate < date('2021-02-01')) - OR (id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' AND daydate not between date('2021-02-01') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by rp.startdate,rp.enddate) - sper ) prp where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' and id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-08-01') and date('2023-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and sr.daydate between date('2022-08-01') and date(date_trunc('week',date('2023-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= '0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days') - --where id_staff= '0bfc88e6-76fe-24a7-78b9-adbdff787413' and daydate between date('2022-08-01') and date('2023-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd6b04e48-367a-6b0b-0aa2-d8f956df55e2') - where pd.id_staff='0bfc88e6-76fe-24a7-78b9-adbdff787413' and pd.daydate between date('2022-08-01') and date('2023-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '0bfc88e6-76fe-24a7-78b9-adbdff787413' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id from lousdiner.reportperiod order by startdate,enddate; -QUERYARRAY: select id,startdate,enddate from lousdiner.reportperiod where -startdate >= date((select min(startdate) from lousdiner.staffcontract where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b')) -or date((select min(startdate) from lousdiner.staffcontract where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b')) between startdate and enddate order by startdate,enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-04-14'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-04-12'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and (daydate > date('2023-02-05') or daydate < date('2021-04-12')) - OR (id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' AND daydate not between date('2021-04-12') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('bec92b1d-4b99-4aad-ddcb-a693b929acd7','ef90b898-96ad-f5f1-b0b9-ad9a4d95320b') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-04-14'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-04-12'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and (daydate > date('2023-02-05') or daydate < date('2021-04-12')) - OR (id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' AND daydate not between date('2021-04-12') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('6748aadc-7171-bc73-a0b3-e097b8fa8716','ef90b898-96ad-f5f1-b0b9-ad9a4d95320b') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-04-14'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-04-12'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and (daydate > date('2023-02-05') or daydate < date('2021-04-12')) - OR (id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' AND daydate not between date('2021-04-12') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8','ef90b898-96ad-f5f1-b0b9-ad9a4d95320b') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-04-14'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-04-12'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and (daydate > date('2023-02-05') or daydate < date('2021-04-12')) - OR (id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' AND daydate not between date('2021-04-12') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' group by rp.id); -EXEC: INSERT INTO lousdiner.staffreportperiod (id_reportperiod, id_staff) - VALUES ('d6b04e48-367a-6b0b-0aa2-d8f956df55e2','ef90b898-96ad-f5f1-b0b9-ad9a4d95320b') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select reportperiodunit,reportperiodlength from public.companies where schemata='lousdiner' -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ) scx where startdate < enddate and id='bec92b1d-4b99-4aad-ddcb-a693b929acd7' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-04-14'),date('2021-07-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 78 as maxdays,78 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date('2021-02-01') and date('2021-07-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-07-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-07-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=78,contracthours='624:00:00' where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by rp.startdate,rp.enddate) - sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-02-01') and date('2021-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days') - --where id_staff= 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date('2021-02-01') and date('2021-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7') - where pd.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and pd.daydate between date('2021-02-01') and date('2021-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ) scx where startdate < enddate and id='6748aadc-7171-bc73-a0b3-e097b8fa8716' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-08-01'),date('2022-01-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 131 as maxdays,131 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date('2021-08-01') and date('2022-01-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2022-01-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2022-01-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=131,contracthours='1048:00:00' where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select * from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by rp.startdate,rp.enddate) - sper ) prp where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='bec92b1d-4b99-4aad-ddcb-a693b929acd7' and id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-08-01') and date('2022-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and sr.daydate between date('2021-08-01') and date(date_trunc('week',date('2022-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days') - --where id_staff= 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date('2021-08-01') and date('2022-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '6748aadc-7171-bc73-a0b3-e097b8fa8716') - where pd.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and pd.daydate between date('2021-08-01') and date('2022-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ) scx where startdate < enddate and id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2022-02-01'),date('2022-07-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 129 as maxdays,129 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date('2022-02-01') and date('2022-07-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2022-07-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2022-07-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=129,contracthours='1032:00:00' where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select * from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by rp.startdate,rp.enddate) - sper ) prp where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='6748aadc-7171-bc73-a0b3-e097b8fa8716' and id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-02-01') and date('2022-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and sr.daydate between date('2022-02-01') and date(date_trunc('week',date('2022-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days') - --where id_staff= 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date('2022-02-01') and date('2022-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8') - where pd.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and pd.daydate between date('2022-02-01') and date('2022-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from lousdiner.staffcontract sc - cross join lousdiner.reportperiod rp - where sc.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ) scx where startdate < enddate and id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2022-08-01'),date('2023-01-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 132 as maxdays,132 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from lousdiner.staffreportperioddays - where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date('2022-08-01') and date('2023-01-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2023-01-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2023-01-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from lousdiner.staffcontract where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update lousdiner.staffreportperiod set maxdays=132,contracthours='1056:00:00' where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select * from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by rp.startdate,rp.enddate) - sper ) prp where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' and id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-08-01') and date('2023-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and sr.daydate between date('2022-08-01') and date(date_trunc('week',date('2023-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days') - --where id_staff= 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date('2022-08-01') and date('2023-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd6b04e48-367a-6b0b-0aa2-d8f956df55e2') - where pd.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and pd.daydate between date('2022-08-01') and date('2023-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -EXEC: insert into lousdiner.staffvacancyyear (id_staff,vacyear) - select id_staff,to_char(daydate,'YYYY')::int4 as vyear from lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' group by id_staff,vyear order by id_staff,vyear - on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-04-14'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-04-12'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and (daydate > date('2023-02-05') or daydate < date('2021-04-12')) - OR (id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' AND daydate not between date('2021-04-12') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by rp.startdate,rp.enddate) - sper ) prp where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-02-01') and date('2021-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and sr.daydate between date('2021-02-01') and date(date_trunc('week',date('2021-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2021-02-01'))) and date(date_trunc('week',date('2021-07-31')) + interval '6 days') - --where id_staff= 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date('2021-02-01') and date('2021-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7') - where pd.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and pd.daydate between date('2021-02-01') and date('2021-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-04-14'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-04-12'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and (daydate > date('2023-02-05') or daydate < date('2021-04-12')) - OR (id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' AND daydate not between date('2021-04-12') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by rp.startdate,rp.enddate) - sper ) prp where id='6748aadc-7171-bc73-a0b3-e097b8fa8716'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='bec92b1d-4b99-4aad-ddcb-a693b929acd7' and id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2021-08-01') and date('2022-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and sr.daydate between date('2021-08-01') and date(date_trunc('week',date('2022-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2021-08-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days') - --where id_staff= 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date('2021-08-01') and date('2022-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '6748aadc-7171-bc73-a0b3-e097b8fa8716') - where pd.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and pd.daydate between date('2021-08-01') and date('2022-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-04-14'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-04-12'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and (daydate > date('2023-02-05') or daydate < date('2021-04-12')) - OR (id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' AND daydate not between date('2021-04-12') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by rp.startdate,rp.enddate) - sper ) prp where id='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='6748aadc-7171-bc73-a0b3-e097b8fa8716' and id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-02-01') and date('2022-07-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-02-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and sr.daydate between date('2022-02-01') and date(date_trunc('week',date('2022-07-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-07-31')) + interval '6 days') - --where id_staff= 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date('2022-02-01') and date('2022-07-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8') - where pd.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and pd.daydate between date('2022-02-01') and date('2022-07-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='lousdiner' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from lousdiner.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' as id_staff from lousdiner.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-04-14'))) as firstday , date(date_trunc('week',date('2023-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into lousdiner.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-04-12'::timestamp,'2023-02-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and (daydate > date('2023-02-05') or daydate < date('2021-04-12')) - OR (id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' AND daydate not between date('2021-04-12') and date('2023-02-05')); -EXEC: delete from lousdiner.staffreportperiod sp where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod not in ( -select rp.id from lousdiner.reportperiod rp left join lousdiner.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' group by rp.id); -QUERY: select * from lousdiner.reportperiod where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from lousdiner.staffreportperiod srp - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by rp.startdate,rp.enddate) - sper ) prp where id='d6b04e48-367a-6b0b-0aa2-d8f956df55e2'; -EXEC: update lousdiner.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from lousdiner.staffreportperioddays where id in (select id from lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update lousdiner.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from lousdiner.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from lousdiner.staffreportperioddays where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from lousdiner.staffreportperiod where id_reportperiod='0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' and id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from lousdiner.staffreportperioddays -where daydate between date('2022-08-01') and date('2023-01-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from lousdiner.staffreportperiod where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and id_reportperiod in (select id from lousdiner.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-08-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and sr.daydate between date('2022-08-01') and date(date_trunc('week',date('2023-01-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date(date_trunc('week',date('2022-08-01'))) and date(date_trunc('week',date('2023-01-31')) + interval '6 days') - --where id_staff= 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and daydate between date('2022-08-01') and date('2023-01-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update lousdiner.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 lousdiner.staffreportperioddays pd - join lousdiner.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd6b04e48-367a-6b0b-0aa2-d8f956df55e2') - where pd.id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' and pd.daydate between date('2022-08-01') and date('2023-01-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = '6748aadc-7171-bc73-a0b3-e097b8fa8716' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = '0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = '6748aadc-7171-bc73-a0b3-e097b8fa8716' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = '0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = 'd6b04e48-367a-6b0b-0aa2-d8f956df55e2' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = '0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = '6748aadc-7171-bc73-a0b3-e097b8fa8716' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: 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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select sessiondata from public.sessions where id='6cfa9047-f585-a84b-62b0-0e0a53c9fd08' -EXEC: update public.sessions set sessiondata='{"schemata":"kraeltgen"}' where id='6cfa9047-f585-a84b-62b0-0e0a53c9fd08' -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: 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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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 kraeltgen.reportperiod rp ORDER BY startdate, enddate; -_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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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_reportperiod = '35fda5d9-36ef-528b-4339-286589719039' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id from kraeltgen.staff where isdeleted is null; -QUERYARRAY: select id from kraeltgen.reportperiod order by startdate,enddate; -QUERYARRAY: select id,startdate,enddate from kraeltgen.reportperiod where -startdate >= date((select min(startdate) from kraeltgen.staffcontract where id_staff='97648c64-05b7-516a-48a2-23d31511451a')) -or date((select min(startdate) from kraeltgen.staffcontract where id_staff='97648c64-05b7-516a-48a2-23d31511451a')) between startdate and enddate order by startdate,enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-01'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-26'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and (daydate > date('2022-07-03') or daydate < date('2021-07-26')) - OR (id_staff='97648c64-05b7-516a-48a2-23d31511451a' AND daydate not between date('2021-07-26') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('a0538335-1f82-8312-8a62-2e42ea74ed20','97648c64-05b7-516a-48a2-23d31511451a') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-01'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-26'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and (daydate > date('2022-07-03') or daydate < date('2021-07-26')) - OR (id_staff='97648c64-05b7-516a-48a2-23d31511451a' AND daydate not between date('2021-07-26') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('ec6261df-f5df-d1b9-7ca1-639d79e82bfe','97648c64-05b7-516a-48a2-23d31511451a') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-01'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-26'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and (daydate > date('2022-07-03') or daydate < date('2021-07-26')) - OR (id_staff='97648c64-05b7-516a-48a2-23d31511451a' AND daydate not between date('2021-07-26') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('d1fe1b59-0129-bb85-53da-a4f9f69d9b83','97648c64-05b7-516a-48a2-23d31511451a') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-01'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-26'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and (daydate > date('2022-07-03') or daydate < date('2021-07-26')) - OR (id_staff='97648c64-05b7-516a-48a2-23d31511451a' AND daydate not between date('2021-07-26') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('35fda5d9-36ef-528b-4339-286589719039','97648c64-05b7-516a-48a2-23d31511451a') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select reportperiodunit,reportperiodlength from public.companies where schemata='kraeltgen' -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' - ) scx where startdate < enddate and id='a0538335-1f82-8312-8a62-2e42ea74ed20' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-08-01'),date('2021-08-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 21 as maxdays,21 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2021-07-01') and date('2021-08-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-08-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-08-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='97648c64-05b7-516a-48a2-23d31511451a' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=21,contracthours='168:00:00' where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select * from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by rp.startdate,rp.enddate) - sper ) prp where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-07-01') and date('2021-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-07-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and sr.daydate between date('2021-07-01') and date(date_trunc('week',date('2021-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days') - --where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2021-07-01') and date('2021-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=3,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2021-08-30'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a0538335-1f82-8312-8a62-2e42ea74ed20') - where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and pd.daydate between date('2021-07-01') and date('2021-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' - ) scx where startdate < enddate and id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-09-01'),date('2021-10-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 45 as maxdays,45 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2021-09-01') and date('2021-10-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-10-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-10-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='97648c64-05b7-516a-48a2-23d31511451a' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=45,contracthours='360:00:00' where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -QUERY: select * from kraeltgen.reportperiod where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by rp.startdate,rp.enddate) - sper ) prp where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='a0538335-1f82-8312-8a62-2e42ea74ed20' and id_staff='97648c64-05b7-516a-48a2-23d31511451a'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,3+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-09-01') and date('2021-10-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,2+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and sr.daydate between date('2021-08-30') and date(date_trunc('week',date('2021-10-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days') - --where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2021-09-01') and date('2021-10-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=12,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2021-10-25'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'ec6261df-f5df-d1b9-7ca1-639d79e82bfe') - where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and pd.daydate between date('2021-09-01') and date('2021-10-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' - ) scx where startdate < enddate and id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-11-01'),date('2021-12-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 43 as maxdays,43 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2021-11-01') and date('2021-12-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-12-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-12-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='97648c64-05b7-516a-48a2-23d31511451a' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=43,contracthours='344:00:00' where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -QUERY: select * from kraeltgen.reportperiod where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by rp.startdate,rp.enddate) - sper ) prp where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='ec6261df-f5df-d1b9-7ca1-639d79e82bfe' and id_staff='97648c64-05b7-516a-48a2-23d31511451a'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,12+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-11-01') and date('2021-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-11-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,3+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and sr.daydate between date('2021-10-25') and date(date_trunc('week',date('2021-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days') - --where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2021-11-01') and date('2021-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=19,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=6,last44date=date('2021-12-27'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd1fe1b59-0129-bb85-53da-a4f9f69d9b83') - where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and pd.daydate between date('2021-11-01') and date('2021-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' - ) scx where startdate < enddate and id='35fda5d9-36ef-528b-4339-286589719039' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2022-01-01'),date('2022-06-30'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 129 as maxdays,129 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2022-01-01') and date('2022-06-30') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2022-06-30') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2022-06-30')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='97648c64-05b7-516a-48a2-23d31511451a' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=129,contracthours='1032:00:00' where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod='35fda5d9-36ef-528b-4339-286589719039'; -QUERY: select * from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by rp.startdate,rp.enddate) - sper ) prp where id='35fda5d9-36ef-528b-4339-286589719039'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='d1fe1b59-0129-bb85-53da-a4f9f69d9b83' and id_staff='97648c64-05b7-516a-48a2-23d31511451a'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,19+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2022-01-01') and date('2022-06-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,6+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and sr.daydate between date('2021-12-27') and date(date_trunc('week',date('2022-06-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days') - --where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2022-01-01') and date('2022-06-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=35,suppvacancysunwork=2,suppvacancy44hours=1,status44hcount=1,last44date=date('2022-05-02'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '35fda5d9-36ef-528b-4339-286589719039') - where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and pd.daydate between date('2022-01-01') and date('2022-06-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -EXEC: insert into kraeltgen.staffvacancyyear (id_staff,vacyear) - select id_staff,to_char(daydate,'YYYY')::int4 as vyear from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by id_staff,vyear order by id_staff,vyear - on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-01'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-26'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and (daydate > date('2022-07-03') or daydate < date('2021-07-26')) - OR (id_staff='97648c64-05b7-516a-48a2-23d31511451a' AND daydate not between date('2021-07-26') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by rp.startdate,rp.enddate) - sper ) prp where id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-01-01'))) and date(date_trunc('week',date('2020-02-29')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-01-01'))) and date(date_trunc('week',date('2020-02-29')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-01-01') and date('2020-02-29') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and sr.daydate between date('2020-01-01') and date(date_trunc('week',date('2020-02-29')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-01-01'))) and date(date_trunc('week',date('2020-02-29')) + interval '6 days') - --where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2020-01-01') and date('2020-02-29') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '529236a0-bb8e-c0dd-6dfd-406fe2f59aff') - where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and pd.daydate between date('2020-01-01') and date('2020-02-29') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='872690b5-74c8-6eb3-2c9c-2ad47ea57995'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-01'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-26'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and (daydate > date('2022-07-03') or daydate < date('2021-07-26')) - OR (id_staff='97648c64-05b7-516a-48a2-23d31511451a' AND daydate not between date('2021-07-26') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='872690b5-74c8-6eb3-2c9c-2ad47ea57995'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by rp.startdate,rp.enddate) - sper ) prp where id='872690b5-74c8-6eb3-2c9c-2ad47ea57995'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-03-01'))) and date(date_trunc('week',date('2020-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-03-01'))) and date(date_trunc('week',date('2020-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-03-01') and date('2020-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-03-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and sr.daydate between date('2020-03-01') and date(date_trunc('week',date('2020-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-03-01'))) and date(date_trunc('week',date('2020-04-30')) + interval '6 days') - --where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2020-03-01') and date('2020-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '872690b5-74c8-6eb3-2c9c-2ad47ea57995') - where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and pd.daydate between date('2020-03-01') and date('2020-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='c70d0d68-b69f-2b02-cec3-d82b47eca9b6'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-01'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-26'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and (daydate > date('2022-07-03') or daydate < date('2021-07-26')) - OR (id_staff='97648c64-05b7-516a-48a2-23d31511451a' AND daydate not between date('2021-07-26') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='c70d0d68-b69f-2b02-cec3-d82b47eca9b6'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by rp.startdate,rp.enddate) - sper ) prp where id='c70d0d68-b69f-2b02-cec3-d82b47eca9b6'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-05-01'))) and date(date_trunc('week',date('2020-06-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-05-01'))) and date(date_trunc('week',date('2020-06-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-05-01') and date('2020-06-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and sr.daydate between date('2020-05-01') and date(date_trunc('week',date('2020-06-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-05-01'))) and date(date_trunc('week',date('2020-06-30')) + interval '6 days') - --where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2020-05-01') and date('2020-06-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'c70d0d68-b69f-2b02-cec3-d82b47eca9b6') - where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and pd.daydate between date('2020-05-01') and date('2020-06-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-01'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-26'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and (daydate > date('2022-07-03') or daydate < date('2021-07-26')) - OR (id_staff='97648c64-05b7-516a-48a2-23d31511451a' AND daydate not between date('2021-07-26') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by rp.startdate,rp.enddate) - sper ) prp where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-07-01') and date('2020-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-07-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and sr.daydate between date('2020-07-01') and date(date_trunc('week',date('2020-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days') - --where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2020-07-01') and date('2020-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'f9ed771d-6236-f6f3-caa7-e678a49023d0') - where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and pd.daydate between date('2020-07-01') and date('2020-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-01'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-26'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and (daydate > date('2022-07-03') or daydate < date('2021-07-26')) - OR (id_staff='97648c64-05b7-516a-48a2-23d31511451a' AND daydate not between date('2021-07-26') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by rp.startdate,rp.enddate) - sper ) prp where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-09-01') and date('2020-10-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and sr.daydate between date('2020-09-01') and date(date_trunc('week',date('2020-10-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days') - --where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2020-09-01') and date('2020-10-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '1f489513-7b98-efb4-d16d-f3baeceb846a') - where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and pd.daydate between date('2020-09-01') and date('2020-10-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-01'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-26'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and (daydate > date('2022-07-03') or daydate < date('2021-07-26')) - OR (id_staff='97648c64-05b7-516a-48a2-23d31511451a' AND daydate not between date('2021-07-26') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by rp.startdate,rp.enddate) - sper ) prp where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-11-01') and date('2020-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-11-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and sr.daydate between date('2020-11-01') and date(date_trunc('week',date('2020-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days') - --where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2020-11-01') and date('2020-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '83f75caf-b28e-5c31-cd74-d7a7bd23e960') - where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and pd.daydate between date('2020-11-01') and date('2020-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-01'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-26'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and (daydate > date('2022-07-03') or daydate < date('2021-07-26')) - OR (id_staff='97648c64-05b7-516a-48a2-23d31511451a' AND daydate not between date('2021-07-26') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by rp.startdate,rp.enddate) - sper ) prp where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-01-01') and date('2021-02-28') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and sr.daydate between date('2021-01-01') and date(date_trunc('week',date('2021-02-28')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days') - --where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2021-01-01') and date('2021-02-28') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'da4487e9-aaf6-ee29-0718-0e6b61ab9ebc') - where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and pd.daydate between date('2021-01-01') and date('2021-02-28') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='d85f8825-82dc-ff12-24c3-94e2967d22c0'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-01'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-26'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and (daydate > date('2022-07-03') or daydate < date('2021-07-26')) - OR (id_staff='97648c64-05b7-516a-48a2-23d31511451a' AND daydate not between date('2021-07-26') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='d85f8825-82dc-ff12-24c3-94e2967d22c0'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by rp.startdate,rp.enddate) - sper ) prp where id='d85f8825-82dc-ff12-24c3-94e2967d22c0'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-03-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-03-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-03-01') and date('2021-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-03-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and sr.daydate between date('2021-03-01') and date(date_trunc('week',date('2021-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-03-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days') - --where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2021-03-01') and date('2021-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd85f8825-82dc-ff12-24c3-94e2967d22c0') - where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and pd.daydate between date('2021-03-01') and date('2021-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-01'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-26'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and (daydate > date('2022-07-03') or daydate < date('2021-07-26')) - OR (id_staff='97648c64-05b7-516a-48a2-23d31511451a' AND daydate not between date('2021-07-26') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by rp.startdate,rp.enddate) - sper ) prp where id='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-06-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-06-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-05-01') and date('2021-06-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and sr.daydate between date('2021-05-01') and date(date_trunc('week',date('2021-06-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-06-30')) + interval '6 days') - --where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2021-05-01') and date('2021-06-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1') - where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and pd.daydate between date('2021-05-01') and date('2021-06-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-01'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-26'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and (daydate > date('2022-07-03') or daydate < date('2021-07-26')) - OR (id_staff='97648c64-05b7-516a-48a2-23d31511451a' AND daydate not between date('2021-07-26') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by rp.startdate,rp.enddate) - sper ) prp where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-07-01') and date('2021-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-07-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and sr.daydate between date('2021-07-01') and date(date_trunc('week',date('2021-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days') - --where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2021-07-01') and date('2021-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=3,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2021-08-30'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a0538335-1f82-8312-8a62-2e42ea74ed20') - where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and pd.daydate between date('2021-07-01') and date('2021-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-01'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-26'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and (daydate > date('2022-07-03') or daydate < date('2021-07-26')) - OR (id_staff='97648c64-05b7-516a-48a2-23d31511451a' AND daydate not between date('2021-07-26') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by rp.startdate,rp.enddate) - sper ) prp where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='a0538335-1f82-8312-8a62-2e42ea74ed20' and id_staff='97648c64-05b7-516a-48a2-23d31511451a'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,3+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-09-01') and date('2021-10-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,2+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and sr.daydate between date('2021-08-30') and date(date_trunc('week',date('2021-10-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days') - --where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2021-09-01') and date('2021-10-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=12,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2021-10-25'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'ec6261df-f5df-d1b9-7ca1-639d79e82bfe') - where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and pd.daydate between date('2021-09-01') and date('2021-10-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-01'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-26'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and (daydate > date('2022-07-03') or daydate < date('2021-07-26')) - OR (id_staff='97648c64-05b7-516a-48a2-23d31511451a' AND daydate not between date('2021-07-26') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by rp.startdate,rp.enddate) - sper ) prp where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='ec6261df-f5df-d1b9-7ca1-639d79e82bfe' and id_staff='97648c64-05b7-516a-48a2-23d31511451a'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,12+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-11-01') and date('2021-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-11-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,3+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and sr.daydate between date('2021-10-25') and date(date_trunc('week',date('2021-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days') - --where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2021-11-01') and date('2021-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=19,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=6,last44date=date('2021-12-27'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd1fe1b59-0129-bb85-53da-a4f9f69d9b83') - where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and pd.daydate between date('2021-11-01') and date('2021-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-01'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'97648c64-05b7-516a-48a2-23d31511451a' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-26'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and (daydate > date('2022-07-03') or daydate < date('2021-07-26')) - OR (id_staff='97648c64-05b7-516a-48a2-23d31511451a' AND daydate not between date('2021-07-26') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by rp.startdate,rp.enddate) - sper ) prp where id='35fda5d9-36ef-528b-4339-286589719039'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='d1fe1b59-0129-bb85-53da-a4f9f69d9b83' and id_staff='97648c64-05b7-516a-48a2-23d31511451a'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,19+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2022-01-01') and date('2022-06-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='97648c64-05b7-516a-48a2-23d31511451a' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='97648c64-05b7-516a-48a2-23d31511451a' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,6+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and sr.daydate between date('2021-12-27') and date(date_trunc('week',date('2022-06-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days') - --where id_staff= '97648c64-05b7-516a-48a2-23d31511451a' and daydate between date('2022-01-01') and date('2022-06-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=35,suppvacancysunwork=2,suppvacancy44hours=1,status44hcount=1,last44date=date('2022-05-02'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '35fda5d9-36ef-528b-4339-286589719039') - where pd.id_staff='97648c64-05b7-516a-48a2-23d31511451a' and pd.daydate between date('2022-01-01') and date('2022-06-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '97648c64-05b7-516a-48a2-23d31511451a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id from kraeltgen.reportperiod order by startdate,enddate; -QUERYARRAY: select id,startdate,enddate from kraeltgen.reportperiod where -startdate >= date((select min(startdate) from kraeltgen.staffcontract where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373')) -or date((select min(startdate) from kraeltgen.staffcontract where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373')) between startdate and enddate order by startdate,enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('f9ed771d-6236-f6f3-caa7-e678a49023d0','d20e29fd-921a-9396-f0cb-2262f9435373') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('1f489513-7b98-efb4-d16d-f3baeceb846a','d20e29fd-921a-9396-f0cb-2262f9435373') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('83f75caf-b28e-5c31-cd74-d7a7bd23e960','d20e29fd-921a-9396-f0cb-2262f9435373') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('da4487e9-aaf6-ee29-0718-0e6b61ab9ebc','d20e29fd-921a-9396-f0cb-2262f9435373') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='d85f8825-82dc-ff12-24c3-94e2967d22c0'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('d85f8825-82dc-ff12-24c3-94e2967d22c0','d20e29fd-921a-9396-f0cb-2262f9435373') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1','d20e29fd-921a-9396-f0cb-2262f9435373') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('a0538335-1f82-8312-8a62-2e42ea74ed20','d20e29fd-921a-9396-f0cb-2262f9435373') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('ec6261df-f5df-d1b9-7ca1-639d79e82bfe','d20e29fd-921a-9396-f0cb-2262f9435373') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('d1fe1b59-0129-bb85-53da-a4f9f69d9b83','d20e29fd-921a-9396-f0cb-2262f9435373') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('35fda5d9-36ef-528b-4339-286589719039','d20e29fd-921a-9396-f0cb-2262f9435373') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select reportperiodunit,reportperiodlength from public.companies where schemata='kraeltgen' -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' - ) scx where startdate < enddate and id='f9ed771d-6236-f6f3-caa7-e678a49023d0' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2020-08-01'),date('2020-08-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 22 as maxdays,22 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2020-07-01') and date('2020-08-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2020-08-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2020-08-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=22,contracthours='176:00:00' where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -QUERY: select * from kraeltgen.reportperiod where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by rp.startdate,rp.enddate) - sper ) prp where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-07-01') and date('2020-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-07-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and sr.daydate between date('2020-07-01') and date(date_trunc('week',date('2020-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days') - --where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2020-07-01') and date('2020-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'f9ed771d-6236-f6f3-caa7-e678a49023d0') - where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and pd.daydate between date('2020-07-01') and date('2020-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'd20e29fd-921a-9396-f0cb-2262f9435373' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' - ) scx where startdate < enddate and id='1f489513-7b98-efb4-d16d-f3baeceb846a' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2020-09-01'),date('2020-10-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 44 as maxdays,44 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2020-09-01') and date('2020-10-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2020-10-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2020-10-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=44,contracthours='352:00:00' where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod='1f489513-7b98-efb4-d16d-f3baeceb846a'; -QUERY: select * from kraeltgen.reportperiod where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by rp.startdate,rp.enddate) - sper ) prp where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='f9ed771d-6236-f6f3-caa7-e678a49023d0' and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-09-01') and date('2020-10-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and sr.daydate between date('2020-09-01') and date(date_trunc('week',date('2020-10-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days') - --where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2020-09-01') and date('2020-10-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '1f489513-7b98-efb4-d16d-f3baeceb846a') - where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and pd.daydate between date('2020-09-01') and date('2020-10-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'd20e29fd-921a-9396-f0cb-2262f9435373' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' - ) scx where startdate < enddate and id='83f75caf-b28e-5c31-cd74-d7a7bd23e960' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2020-11-01'),date('2020-12-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 43 as maxdays,43 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2020-11-01') and date('2020-12-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2020-12-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2020-12-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=43,contracthours='344:00:00' where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -QUERY: select * from kraeltgen.reportperiod where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by rp.startdate,rp.enddate) - sper ) prp where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='1f489513-7b98-efb4-d16d-f3baeceb846a' and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-11-01') and date('2020-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-11-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and sr.daydate between date('2020-11-01') and date(date_trunc('week',date('2020-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days') - --where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2020-11-01') and date('2020-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '83f75caf-b28e-5c31-cd74-d7a7bd23e960') - where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and pd.daydate between date('2020-11-01') and date('2020-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'd20e29fd-921a-9396-f0cb-2262f9435373' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' - ) scx where startdate < enddate and id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-01-01'),date('2021-01-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 23 as maxdays,23 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2021-01-01') and date('2021-02-28') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-02-28') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-02-28')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=23,contracthours='184:00:00' where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -QUERY: select * from kraeltgen.reportperiod where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by rp.startdate,rp.enddate) - sper ) prp where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='83f75caf-b28e-5c31-cd74-d7a7bd23e960' and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-01-01') and date('2021-02-28') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and sr.daydate between date('2021-01-01') and date(date_trunc('week',date('2021-02-28')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days') - --where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2021-01-01') and date('2021-02-28') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'da4487e9-aaf6-ee29-0718-0e6b61ab9ebc') - where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and pd.daydate between date('2021-01-01') and date('2021-02-28') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'd20e29fd-921a-9396-f0cb-2262f9435373' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' - ) scx where startdate < enddate and id='d85f8825-82dc-ff12-24c3-94e2967d22c0' order by startdate,enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' - ) scx where startdate < enddate and id='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1' order by startdate,enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' - ) scx where startdate < enddate and id='a0538335-1f82-8312-8a62-2e42ea74ed20' order by startdate,enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' - ) scx where startdate < enddate and id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe' order by startdate,enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' - ) scx where startdate < enddate and id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83' order by startdate,enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' - ) scx where startdate < enddate and id='35fda5d9-36ef-528b-4339-286589719039' order by startdate,enddate; -EXEC: insert into kraeltgen.staffvacancyyear (id_staff,vacyear) - select id_staff,to_char(daydate,'YYYY')::int4 as vyear from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by id_staff,vyear order by id_staff,vyear - on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by rp.startdate,rp.enddate) - sper ) prp where id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-01-01'))) and date(date_trunc('week',date('2020-02-29')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-01-01'))) and date(date_trunc('week',date('2020-02-29')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-01-01') and date('2020-02-29') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and sr.daydate between date('2020-01-01') and date(date_trunc('week',date('2020-02-29')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-01-01'))) and date(date_trunc('week',date('2020-02-29')) + interval '6 days') - --where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2020-01-01') and date('2020-02-29') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '529236a0-bb8e-c0dd-6dfd-406fe2f59aff') - where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and pd.daydate between date('2020-01-01') and date('2020-02-29') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'd20e29fd-921a-9396-f0cb-2262f9435373' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='872690b5-74c8-6eb3-2c9c-2ad47ea57995'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='872690b5-74c8-6eb3-2c9c-2ad47ea57995'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by rp.startdate,rp.enddate) - sper ) prp where id='872690b5-74c8-6eb3-2c9c-2ad47ea57995'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-03-01'))) and date(date_trunc('week',date('2020-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-03-01'))) and date(date_trunc('week',date('2020-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-03-01') and date('2020-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-03-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and sr.daydate between date('2020-03-01') and date(date_trunc('week',date('2020-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-03-01'))) and date(date_trunc('week',date('2020-04-30')) + interval '6 days') - --where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2020-03-01') and date('2020-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '872690b5-74c8-6eb3-2c9c-2ad47ea57995') - where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and pd.daydate between date('2020-03-01') and date('2020-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'd20e29fd-921a-9396-f0cb-2262f9435373' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='c70d0d68-b69f-2b02-cec3-d82b47eca9b6'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='c70d0d68-b69f-2b02-cec3-d82b47eca9b6'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by rp.startdate,rp.enddate) - sper ) prp where id='c70d0d68-b69f-2b02-cec3-d82b47eca9b6'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-05-01'))) and date(date_trunc('week',date('2020-06-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-05-01'))) and date(date_trunc('week',date('2020-06-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-05-01') and date('2020-06-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and sr.daydate between date('2020-05-01') and date(date_trunc('week',date('2020-06-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-05-01'))) and date(date_trunc('week',date('2020-06-30')) + interval '6 days') - --where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2020-05-01') and date('2020-06-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'c70d0d68-b69f-2b02-cec3-d82b47eca9b6') - where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and pd.daydate between date('2020-05-01') and date('2020-06-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'd20e29fd-921a-9396-f0cb-2262f9435373' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by rp.startdate,rp.enddate) - sper ) prp where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-07-01') and date('2020-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-07-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and sr.daydate between date('2020-07-01') and date(date_trunc('week',date('2020-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days') - --where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2020-07-01') and date('2020-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'f9ed771d-6236-f6f3-caa7-e678a49023d0') - where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and pd.daydate between date('2020-07-01') and date('2020-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'd20e29fd-921a-9396-f0cb-2262f9435373' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by rp.startdate,rp.enddate) - sper ) prp where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='f9ed771d-6236-f6f3-caa7-e678a49023d0' and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-09-01') and date('2020-10-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and sr.daydate between date('2020-09-01') and date(date_trunc('week',date('2020-10-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days') - --where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2020-09-01') and date('2020-10-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '1f489513-7b98-efb4-d16d-f3baeceb846a') - where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and pd.daydate between date('2020-09-01') and date('2020-10-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'd20e29fd-921a-9396-f0cb-2262f9435373' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by rp.startdate,rp.enddate) - sper ) prp where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='1f489513-7b98-efb4-d16d-f3baeceb846a' and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-11-01') and date('2020-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-11-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and sr.daydate between date('2020-11-01') and date(date_trunc('week',date('2020-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days') - --where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2020-11-01') and date('2020-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '83f75caf-b28e-5c31-cd74-d7a7bd23e960') - where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and pd.daydate between date('2020-11-01') and date('2020-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'd20e29fd-921a-9396-f0cb-2262f9435373' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by rp.startdate,rp.enddate) - sper ) prp where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='83f75caf-b28e-5c31-cd74-d7a7bd23e960' and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-01-01') and date('2021-02-28') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and sr.daydate between date('2021-01-01') and date(date_trunc('week',date('2021-02-28')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days') - --where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2021-01-01') and date('2021-02-28') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'da4487e9-aaf6-ee29-0718-0e6b61ab9ebc') - where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and pd.daydate between date('2021-01-01') and date('2021-02-28') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'd20e29fd-921a-9396-f0cb-2262f9435373' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='d85f8825-82dc-ff12-24c3-94e2967d22c0'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='d85f8825-82dc-ff12-24c3-94e2967d22c0'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by rp.startdate,rp.enddate) - sper ) prp where id='d85f8825-82dc-ff12-24c3-94e2967d22c0'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-03-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-03-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-03-01') and date('2021-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-03-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and sr.daydate between date('2021-03-01') and date(date_trunc('week',date('2021-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-03-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days') - --where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2021-03-01') and date('2021-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd85f8825-82dc-ff12-24c3-94e2967d22c0') - where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and pd.daydate between date('2021-03-01') and date('2021-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'd20e29fd-921a-9396-f0cb-2262f9435373' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by rp.startdate,rp.enddate) - sper ) prp where id='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-06-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-06-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-05-01') and date('2021-06-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and sr.daydate between date('2021-05-01') and date(date_trunc('week',date('2021-06-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-06-30')) + interval '6 days') - --where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2021-05-01') and date('2021-06-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1') - where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and pd.daydate between date('2021-05-01') and date('2021-06-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'd20e29fd-921a-9396-f0cb-2262f9435373' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by rp.startdate,rp.enddate) - sper ) prp where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-07-01') and date('2021-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-07-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and sr.daydate between date('2021-07-01') and date(date_trunc('week',date('2021-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days') - --where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2021-07-01') and date('2021-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a0538335-1f82-8312-8a62-2e42ea74ed20') - where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and pd.daydate between date('2021-07-01') and date('2021-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'd20e29fd-921a-9396-f0cb-2262f9435373' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by rp.startdate,rp.enddate) - sper ) prp where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-09-01') and date('2021-10-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and sr.daydate between date('2021-09-01') and date(date_trunc('week',date('2021-10-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days') - --where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2021-09-01') and date('2021-10-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'ec6261df-f5df-d1b9-7ca1-639d79e82bfe') - where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and pd.daydate between date('2021-09-01') and date('2021-10-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'd20e29fd-921a-9396-f0cb-2262f9435373' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by rp.startdate,rp.enddate) - sper ) prp where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-11-01') and date('2021-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-11-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and sr.daydate between date('2021-11-01') and date(date_trunc('week',date('2021-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days') - --where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2021-11-01') and date('2021-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd1fe1b59-0129-bb85-53da-a4f9f69d9b83') - where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and pd.daydate between date('2021-11-01') and date('2021-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'd20e29fd-921a-9396-f0cb-2262f9435373' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-08-01'))) as firstday , date(date_trunc('week',date('2021-01-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'d20e29fd-921a-9396-f0cb-2262f9435373' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-07-27'::timestamp,'2021-01-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and (daydate > date('2021-01-31') or daydate < date('2020-07-27')) - OR (id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' AND daydate not between date('2020-07-27') and date('2021-01-31')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by rp.startdate,rp.enddate) - sper ) prp where id='35fda5d9-36ef-528b-4339-286589719039'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2022-01-01') and date('2022-06-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and sr.daydate between date('2022-01-01') and date(date_trunc('week',date('2022-06-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days') - --where id_staff= 'd20e29fd-921a-9396-f0cb-2262f9435373' and daydate between date('2022-01-01') and date('2022-06-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '35fda5d9-36ef-528b-4339-286589719039') - where pd.id_staff='d20e29fd-921a-9396-f0cb-2262f9435373' and pd.daydate between date('2022-01-01') and date('2022-06-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'd20e29fd-921a-9396-f0cb-2262f9435373' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id from kraeltgen.reportperiod order by startdate,enddate; -QUERYARRAY: select id,startdate,enddate from kraeltgen.reportperiod where -startdate >= date((select min(startdate) from kraeltgen.staffcontract where id_staff='92ff737d-651b-8471-8f34-0587a39171db')) -or date((select min(startdate) from kraeltgen.staffcontract where id_staff='92ff737d-651b-8471-8f34-0587a39171db')) between startdate and enddate order by startdate,enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-07-14'))) as firstday , date(date_trunc('week',date('2021-08-22')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-12'::timestamp,'2021-07-25'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/2 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '10:00:00' as wdcontracthours -FROM generate_series( '2021-08-13'::timestamp,'2021-08-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '10:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/3 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '06:40:12' as wdcontracthours -FROM generate_series( '2021-08-20'::timestamp,'2021-08-22'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '06:40:12'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and (daydate > date('2021-08-22') or daydate < date('2021-07-12')) - OR (id_staff='92ff737d-651b-8471-8f34-0587a39171db' AND daydate not between date('2021-07-12') and date('2021-07-25') AND daydate not between date('2021-08-13') and date('2021-08-14') AND daydate not between date('2021-08-20') and date('2021-08-22')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('a0538335-1f82-8312-8a62-2e42ea74ed20','92ff737d-651b-8471-8f34-0587a39171db') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-07-14'))) as firstday , date(date_trunc('week',date('2021-08-22')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-12'::timestamp,'2021-07-25'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/2 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '10:00:00' as wdcontracthours -FROM generate_series( '2021-08-13'::timestamp,'2021-08-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '10:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/3 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '06:40:12' as wdcontracthours -FROM generate_series( '2021-08-20'::timestamp,'2021-08-22'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '06:40:12'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and (daydate > date('2021-08-22') or daydate < date('2021-07-12')) - OR (id_staff='92ff737d-651b-8471-8f34-0587a39171db' AND daydate not between date('2021-07-12') and date('2021-07-25') AND daydate not between date('2021-08-13') and date('2021-08-14') AND daydate not between date('2021-08-20') and date('2021-08-22')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('ec6261df-f5df-d1b9-7ca1-639d79e82bfe','92ff737d-651b-8471-8f34-0587a39171db') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-07-14'))) as firstday , date(date_trunc('week',date('2021-08-22')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-12'::timestamp,'2021-07-25'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/2 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '10:00:00' as wdcontracthours -FROM generate_series( '2021-08-13'::timestamp,'2021-08-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '10:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/3 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '06:40:12' as wdcontracthours -FROM generate_series( '2021-08-20'::timestamp,'2021-08-22'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '06:40:12'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and (daydate > date('2021-08-22') or daydate < date('2021-07-12')) - OR (id_staff='92ff737d-651b-8471-8f34-0587a39171db' AND daydate not between date('2021-07-12') and date('2021-07-25') AND daydate not between date('2021-08-13') and date('2021-08-14') AND daydate not between date('2021-08-20') and date('2021-08-22')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('d1fe1b59-0129-bb85-53da-a4f9f69d9b83','92ff737d-651b-8471-8f34-0587a39171db') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-07-14'))) as firstday , date(date_trunc('week',date('2021-08-22')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-12'::timestamp,'2021-07-25'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/2 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '10:00:00' as wdcontracthours -FROM generate_series( '2021-08-13'::timestamp,'2021-08-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '10:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/3 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '06:40:12' as wdcontracthours -FROM generate_series( '2021-08-20'::timestamp,'2021-08-22'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '06:40:12'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and (daydate > date('2021-08-22') or daydate < date('2021-07-12')) - OR (id_staff='92ff737d-651b-8471-8f34-0587a39171db' AND daydate not between date('2021-07-12') and date('2021-07-25') AND daydate not between date('2021-08-13') and date('2021-08-14') AND daydate not between date('2021-08-20') and date('2021-08-22')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('35fda5d9-36ef-528b-4339-286589719039','92ff737d-651b-8471-8f34-0587a39171db') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select reportperiodunit,reportperiodlength from public.companies where schemata='kraeltgen' -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' - ) scx where startdate < enddate and id='a0538335-1f82-8312-8a62-2e42ea74ed20' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-07-14'),date('2021-07-25'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 10 as maxdays,10 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2021-07-01') and date('2021-08-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-08-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-08-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='92ff737d-651b-8471-8f34-0587a39171db' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=30,contracthours='246:42:00' where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select * from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by rp.startdate,rp.enddate) - sper ) prp where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-07-01') and date('2021-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-07-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and sr.daydate between date('2021-07-01') and date(date_trunc('week',date('2021-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days') - --where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2021-07-01') and date('2021-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=3,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-08-23'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a0538335-1f82-8312-8a62-2e42ea74ed20') - where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and pd.daydate between date('2021-07-01') and date('2021-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '92ff737d-651b-8471-8f34-0587a39171db' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (3,4,5,6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-08-13'),date('2021-08-14'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 0 as maxdays,0 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2021-07-01') and date('2021-08-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-08-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-08-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='92ff737d-651b-8471-8f34-0587a39171db' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=0,contracthours='00:00:00' where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select * from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by rp.startdate,rp.enddate) - sper ) prp where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-07-01') and date('2021-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-07-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and sr.daydate between date('2021-07-01') and date(date_trunc('week',date('2021-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days') - --where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2021-07-01') and date('2021-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=3,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-08-23'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a0538335-1f82-8312-8a62-2e42ea74ed20') - where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and pd.daydate between date('2021-07-01') and date('2021-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '92ff737d-651b-8471-8f34-0587a39171db' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (4,5,6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-08-20'),date('2021-08-22'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 0 as maxdays,0 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2021-07-01') and date('2021-08-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-08-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-08-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='92ff737d-651b-8471-8f34-0587a39171db' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=0,contracthours='00:00:00' where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select * from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by rp.startdate,rp.enddate) - sper ) prp where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-07-01') and date('2021-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-07-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and sr.daydate between date('2021-07-01') and date(date_trunc('week',date('2021-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days') - --where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2021-07-01') and date('2021-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=3,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-08-23'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a0538335-1f82-8312-8a62-2e42ea74ed20') - where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and pd.daydate between date('2021-07-01') and date('2021-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '92ff737d-651b-8471-8f34-0587a39171db' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' - ) scx where startdate < enddate and id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe' order by startdate,enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' - ) scx where startdate < enddate and id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83' order by startdate,enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' - ) scx where startdate < enddate and id='35fda5d9-36ef-528b-4339-286589719039' order by startdate,enddate; -EXEC: insert into kraeltgen.staffvacancyyear (id_staff,vacyear) - select id_staff,to_char(daydate,'YYYY')::int4 as vyear from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by id_staff,vyear order by id_staff,vyear - on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-07-14'))) as firstday , date(date_trunc('week',date('2021-08-22')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-12'::timestamp,'2021-07-25'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/2 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '10:00:00' as wdcontracthours -FROM generate_series( '2021-08-13'::timestamp,'2021-08-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '10:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/3 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '06:40:12' as wdcontracthours -FROM generate_series( '2021-08-20'::timestamp,'2021-08-22'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '06:40:12'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and (daydate > date('2021-08-22') or daydate < date('2021-07-12')) - OR (id_staff='92ff737d-651b-8471-8f34-0587a39171db' AND daydate not between date('2021-07-12') and date('2021-07-25') AND daydate not between date('2021-08-13') and date('2021-08-14') AND daydate not between date('2021-08-20') and date('2021-08-22')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by rp.startdate,rp.enddate) - sper ) prp where id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-01-01'))) and date(date_trunc('week',date('2020-02-29')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-01-01'))) and date(date_trunc('week',date('2020-02-29')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-01-01') and date('2020-02-29') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and sr.daydate between date('2020-01-01') and date(date_trunc('week',date('2020-02-29')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-01-01'))) and date(date_trunc('week',date('2020-02-29')) + interval '6 days') - --where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2020-01-01') and date('2020-02-29') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '529236a0-bb8e-c0dd-6dfd-406fe2f59aff') - where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and pd.daydate between date('2020-01-01') and date('2020-02-29') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '92ff737d-651b-8471-8f34-0587a39171db' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='872690b5-74c8-6eb3-2c9c-2ad47ea57995'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-07-14'))) as firstday , date(date_trunc('week',date('2021-08-22')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-12'::timestamp,'2021-07-25'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/2 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '10:00:00' as wdcontracthours -FROM generate_series( '2021-08-13'::timestamp,'2021-08-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '10:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/3 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '06:40:12' as wdcontracthours -FROM generate_series( '2021-08-20'::timestamp,'2021-08-22'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '06:40:12'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and (daydate > date('2021-08-22') or daydate < date('2021-07-12')) - OR (id_staff='92ff737d-651b-8471-8f34-0587a39171db' AND daydate not between date('2021-07-12') and date('2021-07-25') AND daydate not between date('2021-08-13') and date('2021-08-14') AND daydate not between date('2021-08-20') and date('2021-08-22')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='872690b5-74c8-6eb3-2c9c-2ad47ea57995'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by rp.startdate,rp.enddate) - sper ) prp where id='872690b5-74c8-6eb3-2c9c-2ad47ea57995'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-03-01'))) and date(date_trunc('week',date('2020-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-03-01'))) and date(date_trunc('week',date('2020-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-03-01') and date('2020-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-03-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and sr.daydate between date('2020-03-01') and date(date_trunc('week',date('2020-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-03-01'))) and date(date_trunc('week',date('2020-04-30')) + interval '6 days') - --where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2020-03-01') and date('2020-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '872690b5-74c8-6eb3-2c9c-2ad47ea57995') - where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and pd.daydate between date('2020-03-01') and date('2020-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '92ff737d-651b-8471-8f34-0587a39171db' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='c70d0d68-b69f-2b02-cec3-d82b47eca9b6'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-07-14'))) as firstday , date(date_trunc('week',date('2021-08-22')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-12'::timestamp,'2021-07-25'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/2 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '10:00:00' as wdcontracthours -FROM generate_series( '2021-08-13'::timestamp,'2021-08-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '10:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/3 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '06:40:12' as wdcontracthours -FROM generate_series( '2021-08-20'::timestamp,'2021-08-22'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '06:40:12'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and (daydate > date('2021-08-22') or daydate < date('2021-07-12')) - OR (id_staff='92ff737d-651b-8471-8f34-0587a39171db' AND daydate not between date('2021-07-12') and date('2021-07-25') AND daydate not between date('2021-08-13') and date('2021-08-14') AND daydate not between date('2021-08-20') and date('2021-08-22')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='c70d0d68-b69f-2b02-cec3-d82b47eca9b6'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by rp.startdate,rp.enddate) - sper ) prp where id='c70d0d68-b69f-2b02-cec3-d82b47eca9b6'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-05-01'))) and date(date_trunc('week',date('2020-06-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-05-01'))) and date(date_trunc('week',date('2020-06-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-05-01') and date('2020-06-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and sr.daydate between date('2020-05-01') and date(date_trunc('week',date('2020-06-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-05-01'))) and date(date_trunc('week',date('2020-06-30')) + interval '6 days') - --where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2020-05-01') and date('2020-06-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'c70d0d68-b69f-2b02-cec3-d82b47eca9b6') - where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and pd.daydate between date('2020-05-01') and date('2020-06-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '92ff737d-651b-8471-8f34-0587a39171db' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-07-14'))) as firstday , date(date_trunc('week',date('2021-08-22')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-12'::timestamp,'2021-07-25'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/2 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '10:00:00' as wdcontracthours -FROM generate_series( '2021-08-13'::timestamp,'2021-08-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '10:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/3 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '06:40:12' as wdcontracthours -FROM generate_series( '2021-08-20'::timestamp,'2021-08-22'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '06:40:12'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and (daydate > date('2021-08-22') or daydate < date('2021-07-12')) - OR (id_staff='92ff737d-651b-8471-8f34-0587a39171db' AND daydate not between date('2021-07-12') and date('2021-07-25') AND daydate not between date('2021-08-13') and date('2021-08-14') AND daydate not between date('2021-08-20') and date('2021-08-22')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by rp.startdate,rp.enddate) - sper ) prp where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-07-01') and date('2020-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-07-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and sr.daydate between date('2020-07-01') and date(date_trunc('week',date('2020-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days') - --where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2020-07-01') and date('2020-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'f9ed771d-6236-f6f3-caa7-e678a49023d0') - where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and pd.daydate between date('2020-07-01') and date('2020-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '92ff737d-651b-8471-8f34-0587a39171db' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-07-14'))) as firstday , date(date_trunc('week',date('2021-08-22')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-12'::timestamp,'2021-07-25'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/2 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '10:00:00' as wdcontracthours -FROM generate_series( '2021-08-13'::timestamp,'2021-08-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '10:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/3 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '06:40:12' as wdcontracthours -FROM generate_series( '2021-08-20'::timestamp,'2021-08-22'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '06:40:12'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and (daydate > date('2021-08-22') or daydate < date('2021-07-12')) - OR (id_staff='92ff737d-651b-8471-8f34-0587a39171db' AND daydate not between date('2021-07-12') and date('2021-07-25') AND daydate not between date('2021-08-13') and date('2021-08-14') AND daydate not between date('2021-08-20') and date('2021-08-22')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by rp.startdate,rp.enddate) - sper ) prp where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-09-01') and date('2020-10-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and sr.daydate between date('2020-09-01') and date(date_trunc('week',date('2020-10-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days') - --where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2020-09-01') and date('2020-10-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '1f489513-7b98-efb4-d16d-f3baeceb846a') - where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and pd.daydate between date('2020-09-01') and date('2020-10-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '92ff737d-651b-8471-8f34-0587a39171db' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-07-14'))) as firstday , date(date_trunc('week',date('2021-08-22')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-12'::timestamp,'2021-07-25'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/2 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '10:00:00' as wdcontracthours -FROM generate_series( '2021-08-13'::timestamp,'2021-08-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '10:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/3 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '06:40:12' as wdcontracthours -FROM generate_series( '2021-08-20'::timestamp,'2021-08-22'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '06:40:12'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and (daydate > date('2021-08-22') or daydate < date('2021-07-12')) - OR (id_staff='92ff737d-651b-8471-8f34-0587a39171db' AND daydate not between date('2021-07-12') and date('2021-07-25') AND daydate not between date('2021-08-13') and date('2021-08-14') AND daydate not between date('2021-08-20') and date('2021-08-22')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by rp.startdate,rp.enddate) - sper ) prp where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-11-01') and date('2020-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-11-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and sr.daydate between date('2020-11-01') and date(date_trunc('week',date('2020-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days') - --where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2020-11-01') and date('2020-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '83f75caf-b28e-5c31-cd74-d7a7bd23e960') - where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and pd.daydate between date('2020-11-01') and date('2020-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '92ff737d-651b-8471-8f34-0587a39171db' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-07-14'))) as firstday , date(date_trunc('week',date('2021-08-22')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-12'::timestamp,'2021-07-25'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/2 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '10:00:00' as wdcontracthours -FROM generate_series( '2021-08-13'::timestamp,'2021-08-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '10:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/3 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '06:40:12' as wdcontracthours -FROM generate_series( '2021-08-20'::timestamp,'2021-08-22'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '06:40:12'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and (daydate > date('2021-08-22') or daydate < date('2021-07-12')) - OR (id_staff='92ff737d-651b-8471-8f34-0587a39171db' AND daydate not between date('2021-07-12') and date('2021-07-25') AND daydate not between date('2021-08-13') and date('2021-08-14') AND daydate not between date('2021-08-20') and date('2021-08-22')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by rp.startdate,rp.enddate) - sper ) prp where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-01-01') and date('2021-02-28') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and sr.daydate between date('2021-01-01') and date(date_trunc('week',date('2021-02-28')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days') - --where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2021-01-01') and date('2021-02-28') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'da4487e9-aaf6-ee29-0718-0e6b61ab9ebc') - where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and pd.daydate between date('2021-01-01') and date('2021-02-28') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '92ff737d-651b-8471-8f34-0587a39171db' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='d85f8825-82dc-ff12-24c3-94e2967d22c0'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-07-14'))) as firstday , date(date_trunc('week',date('2021-08-22')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-12'::timestamp,'2021-07-25'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/2 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '10:00:00' as wdcontracthours -FROM generate_series( '2021-08-13'::timestamp,'2021-08-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '10:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/3 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '06:40:12' as wdcontracthours -FROM generate_series( '2021-08-20'::timestamp,'2021-08-22'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '06:40:12'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and (daydate > date('2021-08-22') or daydate < date('2021-07-12')) - OR (id_staff='92ff737d-651b-8471-8f34-0587a39171db' AND daydate not between date('2021-07-12') and date('2021-07-25') AND daydate not between date('2021-08-13') and date('2021-08-14') AND daydate not between date('2021-08-20') and date('2021-08-22')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='d85f8825-82dc-ff12-24c3-94e2967d22c0'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by rp.startdate,rp.enddate) - sper ) prp where id='d85f8825-82dc-ff12-24c3-94e2967d22c0'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-03-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-03-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-03-01') and date('2021-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-03-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and sr.daydate between date('2021-03-01') and date(date_trunc('week',date('2021-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-03-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days') - --where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2021-03-01') and date('2021-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd85f8825-82dc-ff12-24c3-94e2967d22c0') - where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and pd.daydate between date('2021-03-01') and date('2021-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '92ff737d-651b-8471-8f34-0587a39171db' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-07-14'))) as firstday , date(date_trunc('week',date('2021-08-22')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-12'::timestamp,'2021-07-25'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/2 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '10:00:00' as wdcontracthours -FROM generate_series( '2021-08-13'::timestamp,'2021-08-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '10:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/3 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '06:40:12' as wdcontracthours -FROM generate_series( '2021-08-20'::timestamp,'2021-08-22'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '06:40:12'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and (daydate > date('2021-08-22') or daydate < date('2021-07-12')) - OR (id_staff='92ff737d-651b-8471-8f34-0587a39171db' AND daydate not between date('2021-07-12') and date('2021-07-25') AND daydate not between date('2021-08-13') and date('2021-08-14') AND daydate not between date('2021-08-20') and date('2021-08-22')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by rp.startdate,rp.enddate) - sper ) prp where id='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-06-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-06-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-05-01') and date('2021-06-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and sr.daydate between date('2021-05-01') and date(date_trunc('week',date('2021-06-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-06-30')) + interval '6 days') - --where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2021-05-01') and date('2021-06-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1') - where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and pd.daydate between date('2021-05-01') and date('2021-06-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '92ff737d-651b-8471-8f34-0587a39171db' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-07-14'))) as firstday , date(date_trunc('week',date('2021-08-22')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-12'::timestamp,'2021-07-25'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/2 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '10:00:00' as wdcontracthours -FROM generate_series( '2021-08-13'::timestamp,'2021-08-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '10:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/3 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '06:40:12' as wdcontracthours -FROM generate_series( '2021-08-20'::timestamp,'2021-08-22'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '06:40:12'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and (daydate > date('2021-08-22') or daydate < date('2021-07-12')) - OR (id_staff='92ff737d-651b-8471-8f34-0587a39171db' AND daydate not between date('2021-07-12') and date('2021-07-25') AND daydate not between date('2021-08-13') and date('2021-08-14') AND daydate not between date('2021-08-20') and date('2021-08-22')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by rp.startdate,rp.enddate) - sper ) prp where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-07-01') and date('2021-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-07-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and sr.daydate between date('2021-07-01') and date(date_trunc('week',date('2021-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days') - --where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2021-07-01') and date('2021-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=3,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-08-23'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a0538335-1f82-8312-8a62-2e42ea74ed20') - where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and pd.daydate between date('2021-07-01') and date('2021-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '92ff737d-651b-8471-8f34-0587a39171db' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-07-14'))) as firstday , date(date_trunc('week',date('2021-08-22')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-12'::timestamp,'2021-07-25'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/2 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '10:00:00' as wdcontracthours -FROM generate_series( '2021-08-13'::timestamp,'2021-08-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '10:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/3 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '06:40:12' as wdcontracthours -FROM generate_series( '2021-08-20'::timestamp,'2021-08-22'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '06:40:12'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and (daydate > date('2021-08-22') or daydate < date('2021-07-12')) - OR (id_staff='92ff737d-651b-8471-8f34-0587a39171db' AND daydate not between date('2021-07-12') and date('2021-07-25') AND daydate not between date('2021-08-13') and date('2021-08-14') AND daydate not between date('2021-08-20') and date('2021-08-22')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by rp.startdate,rp.enddate) - sper ) prp where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-09-01') and date('2021-10-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and sr.daydate between date('2021-09-01') and date(date_trunc('week',date('2021-10-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days') - --where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2021-09-01') and date('2021-10-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'ec6261df-f5df-d1b9-7ca1-639d79e82bfe') - where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and pd.daydate between date('2021-09-01') and date('2021-10-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '92ff737d-651b-8471-8f34-0587a39171db' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-07-14'))) as firstday , date(date_trunc('week',date('2021-08-22')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-12'::timestamp,'2021-07-25'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/2 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '10:00:00' as wdcontracthours -FROM generate_series( '2021-08-13'::timestamp,'2021-08-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '10:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/3 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '06:40:12' as wdcontracthours -FROM generate_series( '2021-08-20'::timestamp,'2021-08-22'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '06:40:12'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and (daydate > date('2021-08-22') or daydate < date('2021-07-12')) - OR (id_staff='92ff737d-651b-8471-8f34-0587a39171db' AND daydate not between date('2021-07-12') and date('2021-07-25') AND daydate not between date('2021-08-13') and date('2021-08-14') AND daydate not between date('2021-08-20') and date('2021-08-22')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by rp.startdate,rp.enddate) - sper ) prp where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-11-01') and date('2021-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-11-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and sr.daydate between date('2021-11-01') and date(date_trunc('week',date('2021-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days') - --where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2021-11-01') and date('2021-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd1fe1b59-0129-bb85-53da-a4f9f69d9b83') - where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and pd.daydate between date('2021-11-01') and date('2021-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '92ff737d-651b-8471-8f34-0587a39171db' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-07-14'))) as firstday , date(date_trunc('week',date('2021-08-22')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-07-12'::timestamp,'2021-07-25'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/2 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '10:00:00' as wdcontracthours -FROM generate_series( '2021-08-13'::timestamp,'2021-08-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '10:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '20:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/3 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'92ff737d-651b-8471-8f34-0587a39171db' as id_staff, null as payedpause, - '06:40:12' as wdcontracthours -FROM generate_series( '2021-08-20'::timestamp,'2021-08-22'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '06:40:12'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and (daydate > date('2021-08-22') or daydate < date('2021-07-12')) - OR (id_staff='92ff737d-651b-8471-8f34-0587a39171db' AND daydate not between date('2021-07-12') and date('2021-07-25') AND daydate not between date('2021-08-13') and date('2021-08-14') AND daydate not between date('2021-08-20') and date('2021-08-22')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by rp.startdate,rp.enddate) - sper ) prp where id='35fda5d9-36ef-528b-4339-286589719039'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2022-01-01') and date('2022-06-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='92ff737d-651b-8471-8f34-0587a39171db' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='92ff737d-651b-8471-8f34-0587a39171db' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and sr.daydate between date('2022-01-01') and date(date_trunc('week',date('2022-06-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days') - --where id_staff= '92ff737d-651b-8471-8f34-0587a39171db' and daydate between date('2022-01-01') and date('2022-06-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '35fda5d9-36ef-528b-4339-286589719039') - where pd.id_staff='92ff737d-651b-8471-8f34-0587a39171db' and pd.daydate between date('2022-01-01') and date('2022-06-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '92ff737d-651b-8471-8f34-0587a39171db' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id from kraeltgen.reportperiod order by startdate,enddate; -QUERYARRAY: select id,startdate,enddate from kraeltgen.reportperiod where -startdate >= date((select min(startdate) from kraeltgen.staffcontract where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c')) -or date((select min(startdate) from kraeltgen.staffcontract where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c')) between startdate and enddate order by startdate,enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-13'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-08-09'::timestamp,'2021-08-26'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '05:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/1 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '05:00:00' as wdcontracthours -FROM generate_series( '2021-10-03'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '05:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and (daydate > date('2022-07-03') or daydate < date('2021-08-09')) - OR (id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' AND daydate not between date('2021-08-09') and date('2021-08-26') AND daydate not between date('2021-10-03') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('a0538335-1f82-8312-8a62-2e42ea74ed20','e3ed2959-a411-2f14-b40a-27251d8f6d0c') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-13'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-08-09'::timestamp,'2021-08-26'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '05:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/1 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '05:00:00' as wdcontracthours -FROM generate_series( '2021-10-03'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '05:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and (daydate > date('2022-07-03') or daydate < date('2021-08-09')) - OR (id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' AND daydate not between date('2021-08-09') and date('2021-08-26') AND daydate not between date('2021-10-03') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('ec6261df-f5df-d1b9-7ca1-639d79e82bfe','e3ed2959-a411-2f14-b40a-27251d8f6d0c') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-13'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-08-09'::timestamp,'2021-08-26'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '05:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/1 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '05:00:00' as wdcontracthours -FROM generate_series( '2021-10-03'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '05:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and (daydate > date('2022-07-03') or daydate < date('2021-08-09')) - OR (id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' AND daydate not between date('2021-08-09') and date('2021-08-26') AND daydate not between date('2021-10-03') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('d1fe1b59-0129-bb85-53da-a4f9f69d9b83','e3ed2959-a411-2f14-b40a-27251d8f6d0c') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-13'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-08-09'::timestamp,'2021-08-26'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '05:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/1 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '05:00:00' as wdcontracthours -FROM generate_series( '2021-10-03'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '05:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and (daydate > date('2022-07-03') or daydate < date('2021-08-09')) - OR (id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' AND daydate not between date('2021-08-09') and date('2021-08-26') AND daydate not between date('2021-10-03') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('35fda5d9-36ef-528b-4339-286589719039','e3ed2959-a411-2f14-b40a-27251d8f6d0c') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select reportperiodunit,reportperiodlength from public.companies where schemata='kraeltgen' -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ) scx where startdate < enddate and id='a0538335-1f82-8312-8a62-2e42ea74ed20' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-08-13'),date('2021-08-26'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 10 as maxdays,10 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2021-07-01') and date('2021-08-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-08-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-08-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=10,contracthours='80:00:00' where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select * from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by rp.startdate,rp.enddate) - sper ) prp where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-07-01') and date('2021-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-07-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and sr.daydate between date('2021-07-01') and date(date_trunc('week',date('2021-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days') - --where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2021-07-01') and date('2021-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-08-30'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a0538335-1f82-8312-8a62-2e42ea74ed20') - where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and pd.daydate between date('2021-07-01') and date('2021-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ) scx where startdate < enddate and id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2,3,4,5,6) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-10-03'),date('2021-10-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 5 as maxdays,5 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2021-09-01') and date('2021-10-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-10-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-10-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=5,contracthours='25:00:00' where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -QUERY: select * from kraeltgen.reportperiod where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by rp.startdate,rp.enddate) - sper ) prp where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='a0538335-1f82-8312-8a62-2e42ea74ed20' and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,1+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-09-01') and date('2021-10-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,1+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and sr.daydate between date('2021-08-30') and date(date_trunc('week',date('2021-10-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days') - --where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2021-09-01') and date('2021-10-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=6,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2021-10-25'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'ec6261df-f5df-d1b9-7ca1-639d79e82bfe') - where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and pd.daydate between date('2021-09-01') and date('2021-10-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ) scx where startdate < enddate and id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2,3,4,5,6) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-11-01'),date('2021-12-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 8 as maxdays,8 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2021-11-01') and date('2021-12-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-12-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-12-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=8,contracthours='40:00:00' where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -QUERY: select * from kraeltgen.reportperiod where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by rp.startdate,rp.enddate) - sper ) prp where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='ec6261df-f5df-d1b9-7ca1-639d79e82bfe' and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,6+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-11-01') and date('2021-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-11-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,2+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and sr.daydate between date('2021-10-25') and date(date_trunc('week',date('2021-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days') - --where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2021-11-01') and date('2021-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=13,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=4,last44date=date('2021-12-27'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd1fe1b59-0129-bb85-53da-a4f9f69d9b83') - where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and pd.daydate between date('2021-11-01') and date('2021-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ) scx where startdate < enddate and id='35fda5d9-36ef-528b-4339-286589719039' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2,3,4,5,6) then 0 else 1 end as dow from pg_catalog.generate_series(date('2022-01-01'),date('2022-06-30'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 26 as maxdays,26 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2022-01-01') and date('2022-06-30') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2022-06-30') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2022-06-30')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=26,contracthours='130:00:00' where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod='35fda5d9-36ef-528b-4339-286589719039'; -QUERY: select * from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by rp.startdate,rp.enddate) - sper ) prp where id='35fda5d9-36ef-528b-4339-286589719039'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='d1fe1b59-0129-bb85-53da-a4f9f69d9b83' and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,13+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2022-01-01') and date('2022-06-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,4+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and sr.daydate between date('2021-12-27') and date(date_trunc('week',date('2022-06-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days') - --where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2022-01-01') and date('2022-06-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=19,suppvacancysunwork=null,suppvacancy44hours=1,status44hcount=1,last44date=date('2022-03-07'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '35fda5d9-36ef-528b-4339-286589719039') - where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and pd.daydate between date('2022-01-01') and date('2022-06-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -EXEC: insert into kraeltgen.staffvacancyyear (id_staff,vacyear) - select id_staff,to_char(daydate,'YYYY')::int4 as vyear from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by id_staff,vyear order by id_staff,vyear - on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-13'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-08-09'::timestamp,'2021-08-26'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '05:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/1 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '05:00:00' as wdcontracthours -FROM generate_series( '2021-10-03'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '05:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and (daydate > date('2022-07-03') or daydate < date('2021-08-09')) - OR (id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' AND daydate not between date('2021-08-09') and date('2021-08-26') AND daydate not between date('2021-10-03') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by rp.startdate,rp.enddate) - sper ) prp where id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-01-01'))) and date(date_trunc('week',date('2020-02-29')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-01-01'))) and date(date_trunc('week',date('2020-02-29')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-01-01') and date('2020-02-29') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and sr.daydate between date('2020-01-01') and date(date_trunc('week',date('2020-02-29')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-01-01'))) and date(date_trunc('week',date('2020-02-29')) + interval '6 days') - --where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2020-01-01') and date('2020-02-29') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '529236a0-bb8e-c0dd-6dfd-406fe2f59aff') - where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and pd.daydate between date('2020-01-01') and date('2020-02-29') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='872690b5-74c8-6eb3-2c9c-2ad47ea57995'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-13'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-08-09'::timestamp,'2021-08-26'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '05:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/1 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '05:00:00' as wdcontracthours -FROM generate_series( '2021-10-03'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '05:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and (daydate > date('2022-07-03') or daydate < date('2021-08-09')) - OR (id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' AND daydate not between date('2021-08-09') and date('2021-08-26') AND daydate not between date('2021-10-03') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='872690b5-74c8-6eb3-2c9c-2ad47ea57995'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by rp.startdate,rp.enddate) - sper ) prp where id='872690b5-74c8-6eb3-2c9c-2ad47ea57995'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-03-01'))) and date(date_trunc('week',date('2020-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-03-01'))) and date(date_trunc('week',date('2020-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-03-01') and date('2020-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-03-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and sr.daydate between date('2020-03-01') and date(date_trunc('week',date('2020-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-03-01'))) and date(date_trunc('week',date('2020-04-30')) + interval '6 days') - --where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2020-03-01') and date('2020-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '872690b5-74c8-6eb3-2c9c-2ad47ea57995') - where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and pd.daydate between date('2020-03-01') and date('2020-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='c70d0d68-b69f-2b02-cec3-d82b47eca9b6'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-13'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-08-09'::timestamp,'2021-08-26'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '05:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/1 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '05:00:00' as wdcontracthours -FROM generate_series( '2021-10-03'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '05:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and (daydate > date('2022-07-03') or daydate < date('2021-08-09')) - OR (id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' AND daydate not between date('2021-08-09') and date('2021-08-26') AND daydate not between date('2021-10-03') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='c70d0d68-b69f-2b02-cec3-d82b47eca9b6'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by rp.startdate,rp.enddate) - sper ) prp where id='c70d0d68-b69f-2b02-cec3-d82b47eca9b6'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-05-01'))) and date(date_trunc('week',date('2020-06-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-05-01'))) and date(date_trunc('week',date('2020-06-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-05-01') and date('2020-06-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and sr.daydate between date('2020-05-01') and date(date_trunc('week',date('2020-06-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-05-01'))) and date(date_trunc('week',date('2020-06-30')) + interval '6 days') - --where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2020-05-01') and date('2020-06-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'c70d0d68-b69f-2b02-cec3-d82b47eca9b6') - where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and pd.daydate between date('2020-05-01') and date('2020-06-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-13'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-08-09'::timestamp,'2021-08-26'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '05:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/1 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '05:00:00' as wdcontracthours -FROM generate_series( '2021-10-03'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '05:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and (daydate > date('2022-07-03') or daydate < date('2021-08-09')) - OR (id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' AND daydate not between date('2021-08-09') and date('2021-08-26') AND daydate not between date('2021-10-03') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by rp.startdate,rp.enddate) - sper ) prp where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-07-01') and date('2020-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-07-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and sr.daydate between date('2020-07-01') and date(date_trunc('week',date('2020-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days') - --where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2020-07-01') and date('2020-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'f9ed771d-6236-f6f3-caa7-e678a49023d0') - where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and pd.daydate between date('2020-07-01') and date('2020-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-13'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-08-09'::timestamp,'2021-08-26'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '05:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/1 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '05:00:00' as wdcontracthours -FROM generate_series( '2021-10-03'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '05:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and (daydate > date('2022-07-03') or daydate < date('2021-08-09')) - OR (id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' AND daydate not between date('2021-08-09') and date('2021-08-26') AND daydate not between date('2021-10-03') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by rp.startdate,rp.enddate) - sper ) prp where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-09-01') and date('2020-10-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and sr.daydate between date('2020-09-01') and date(date_trunc('week',date('2020-10-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days') - --where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2020-09-01') and date('2020-10-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '1f489513-7b98-efb4-d16d-f3baeceb846a') - where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and pd.daydate between date('2020-09-01') and date('2020-10-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-13'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-08-09'::timestamp,'2021-08-26'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '05:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/1 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '05:00:00' as wdcontracthours -FROM generate_series( '2021-10-03'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '05:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and (daydate > date('2022-07-03') or daydate < date('2021-08-09')) - OR (id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' AND daydate not between date('2021-08-09') and date('2021-08-26') AND daydate not between date('2021-10-03') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by rp.startdate,rp.enddate) - sper ) prp where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-11-01') and date('2020-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-11-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and sr.daydate between date('2020-11-01') and date(date_trunc('week',date('2020-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days') - --where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2020-11-01') and date('2020-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '83f75caf-b28e-5c31-cd74-d7a7bd23e960') - where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and pd.daydate between date('2020-11-01') and date('2020-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-13'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-08-09'::timestamp,'2021-08-26'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '05:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/1 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '05:00:00' as wdcontracthours -FROM generate_series( '2021-10-03'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '05:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and (daydate > date('2022-07-03') or daydate < date('2021-08-09')) - OR (id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' AND daydate not between date('2021-08-09') and date('2021-08-26') AND daydate not between date('2021-10-03') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by rp.startdate,rp.enddate) - sper ) prp where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-01-01') and date('2021-02-28') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and sr.daydate between date('2021-01-01') and date(date_trunc('week',date('2021-02-28')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days') - --where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2021-01-01') and date('2021-02-28') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'da4487e9-aaf6-ee29-0718-0e6b61ab9ebc') - where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and pd.daydate between date('2021-01-01') and date('2021-02-28') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='d85f8825-82dc-ff12-24c3-94e2967d22c0'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-13'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-08-09'::timestamp,'2021-08-26'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '05:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/1 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '05:00:00' as wdcontracthours -FROM generate_series( '2021-10-03'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '05:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and (daydate > date('2022-07-03') or daydate < date('2021-08-09')) - OR (id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' AND daydate not between date('2021-08-09') and date('2021-08-26') AND daydate not between date('2021-10-03') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='d85f8825-82dc-ff12-24c3-94e2967d22c0'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by rp.startdate,rp.enddate) - sper ) prp where id='d85f8825-82dc-ff12-24c3-94e2967d22c0'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-03-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-03-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-03-01') and date('2021-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-03-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and sr.daydate between date('2021-03-01') and date(date_trunc('week',date('2021-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-03-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days') - --where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2021-03-01') and date('2021-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd85f8825-82dc-ff12-24c3-94e2967d22c0') - where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and pd.daydate between date('2021-03-01') and date('2021-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-13'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-08-09'::timestamp,'2021-08-26'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '05:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/1 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '05:00:00' as wdcontracthours -FROM generate_series( '2021-10-03'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '05:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and (daydate > date('2022-07-03') or daydate < date('2021-08-09')) - OR (id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' AND daydate not between date('2021-08-09') and date('2021-08-26') AND daydate not between date('2021-10-03') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by rp.startdate,rp.enddate) - sper ) prp where id='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-06-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-06-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-05-01') and date('2021-06-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and sr.daydate between date('2021-05-01') and date(date_trunc('week',date('2021-06-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-06-30')) + interval '6 days') - --where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2021-05-01') and date('2021-06-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1') - where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and pd.daydate between date('2021-05-01') and date('2021-06-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-13'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-08-09'::timestamp,'2021-08-26'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '05:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/1 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '05:00:00' as wdcontracthours -FROM generate_series( '2021-10-03'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '05:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and (daydate > date('2022-07-03') or daydate < date('2021-08-09')) - OR (id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' AND daydate not between date('2021-08-09') and date('2021-08-26') AND daydate not between date('2021-10-03') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by rp.startdate,rp.enddate) - sper ) prp where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-07-01') and date('2021-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-07-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and sr.daydate between date('2021-07-01') and date(date_trunc('week',date('2021-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days') - --where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2021-07-01') and date('2021-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2021-08-30'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a0538335-1f82-8312-8a62-2e42ea74ed20') - where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and pd.daydate between date('2021-07-01') and date('2021-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-13'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-08-09'::timestamp,'2021-08-26'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '05:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/1 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '05:00:00' as wdcontracthours -FROM generate_series( '2021-10-03'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '05:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and (daydate > date('2022-07-03') or daydate < date('2021-08-09')) - OR (id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' AND daydate not between date('2021-08-09') and date('2021-08-26') AND daydate not between date('2021-10-03') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by rp.startdate,rp.enddate) - sper ) prp where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='a0538335-1f82-8312-8a62-2e42ea74ed20' and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,1+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-09-01') and date('2021-10-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,1+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and sr.daydate between date('2021-08-30') and date(date_trunc('week',date('2021-10-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-10-31')) + interval '6 days') - --where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2021-09-01') and date('2021-10-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=6,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2021-10-25'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'ec6261df-f5df-d1b9-7ca1-639d79e82bfe') - where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and pd.daydate between date('2021-09-01') and date('2021-10-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-13'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-08-09'::timestamp,'2021-08-26'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '05:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/1 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '05:00:00' as wdcontracthours -FROM generate_series( '2021-10-03'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '05:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and (daydate > date('2022-07-03') or daydate < date('2021-08-09')) - OR (id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' AND daydate not between date('2021-08-09') and date('2021-08-26') AND daydate not between date('2021-10-03') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by rp.startdate,rp.enddate) - sper ) prp where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='ec6261df-f5df-d1b9-7ca1-639d79e82bfe' and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,6+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-11-01') and date('2021-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-11-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,2+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and sr.daydate between date('2021-10-25') and date(date_trunc('week',date('2021-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2021-11-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days') - --where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2021-11-01') and date('2021-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=13,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=4,last44date=date('2021-12-27'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd1fe1b59-0129-bb85-53da-a4f9f69d9b83') - where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and pd.daydate between date('2021-11-01') and date('2021-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-08-13'))) as firstday , date(date_trunc('week',date('2022-06-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-08-09'::timestamp,'2021-08-26'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '05:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/1 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e3ed2959-a411-2f14-b40a-27251d8f6d0c' as id_staff, null as payedpause, - '05:00:00' as wdcontracthours -FROM generate_series( '2021-10-03'::timestamp,'2022-07-03'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '05:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and (daydate > date('2022-07-03') or daydate < date('2021-08-09')) - OR (id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' AND daydate not between date('2021-08-09') and date('2021-08-26') AND daydate not between date('2021-10-03') and date('2022-07-03')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by rp.startdate,rp.enddate) - sper ) prp where id='35fda5d9-36ef-528b-4339-286589719039'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='d1fe1b59-0129-bb85-53da-a4f9f69d9b83' and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,13+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2022-01-01') and date('2022-06-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,4+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and sr.daydate between date('2021-12-27') and date(date_trunc('week',date('2022-06-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-06-30')) + interval '6 days') - --where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2022-01-01') and date('2022-06-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=19,suppvacancysunwork=null,suppvacancy44hours=1,status44hcount=1,last44date=date('2022-03-07'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '35fda5d9-36ef-528b-4339-286589719039') - where pd.id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and pd.daydate between date('2022-01-01') and date('2022-06-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id from kraeltgen.reportperiod order by startdate,enddate; -QUERYARRAY: select id,startdate,enddate from kraeltgen.reportperiod where -startdate >= date((select min(startdate) from kraeltgen.staffcontract where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c')) -or date((select min(startdate) from kraeltgen.staffcontract where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c')) between startdate and enddate order by startdate,enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2019-12-30'))) as firstday , date(date_trunc('week',date('2021-08-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2019-12-30'::timestamp,'2021-09-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and (daydate > date('2021-09-05') or daydate < date('2019-12-30')) - OR (id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' AND daydate not between date('2019-12-30') and date('2021-09-05')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('529236a0-bb8e-c0dd-6dfd-406fe2f59aff','2eec5d6c-2cc6-cb11-3439-596e210dea5c') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='872690b5-74c8-6eb3-2c9c-2ad47ea57995'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2019-12-30'))) as firstday , date(date_trunc('week',date('2021-08-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2019-12-30'::timestamp,'2021-09-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and (daydate > date('2021-09-05') or daydate < date('2019-12-30')) - OR (id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' AND daydate not between date('2019-12-30') and date('2021-09-05')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('872690b5-74c8-6eb3-2c9c-2ad47ea57995','2eec5d6c-2cc6-cb11-3439-596e210dea5c') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='c70d0d68-b69f-2b02-cec3-d82b47eca9b6'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2019-12-30'))) as firstday , date(date_trunc('week',date('2021-08-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2019-12-30'::timestamp,'2021-09-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and (daydate > date('2021-09-05') or daydate < date('2019-12-30')) - OR (id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' AND daydate not between date('2019-12-30') and date('2021-09-05')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('c70d0d68-b69f-2b02-cec3-d82b47eca9b6','2eec5d6c-2cc6-cb11-3439-596e210dea5c') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2019-12-30'))) as firstday , date(date_trunc('week',date('2021-08-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2019-12-30'::timestamp,'2021-09-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and (daydate > date('2021-09-05') or daydate < date('2019-12-30')) - OR (id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' AND daydate not between date('2019-12-30') and date('2021-09-05')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('f9ed771d-6236-f6f3-caa7-e678a49023d0','2eec5d6c-2cc6-cb11-3439-596e210dea5c') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2019-12-30'))) as firstday , date(date_trunc('week',date('2021-08-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2019-12-30'::timestamp,'2021-09-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and (daydate > date('2021-09-05') or daydate < date('2019-12-30')) - OR (id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' AND daydate not between date('2019-12-30') and date('2021-09-05')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('1f489513-7b98-efb4-d16d-f3baeceb846a','2eec5d6c-2cc6-cb11-3439-596e210dea5c') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2019-12-30'))) as firstday , date(date_trunc('week',date('2021-08-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2019-12-30'::timestamp,'2021-09-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and (daydate > date('2021-09-05') or daydate < date('2019-12-30')) - OR (id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' AND daydate not between date('2019-12-30') and date('2021-09-05')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('83f75caf-b28e-5c31-cd74-d7a7bd23e960','2eec5d6c-2cc6-cb11-3439-596e210dea5c') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2019-12-30'))) as firstday , date(date_trunc('week',date('2021-08-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2019-12-30'::timestamp,'2021-09-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and (daydate > date('2021-09-05') or daydate < date('2019-12-30')) - OR (id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' AND daydate not between date('2019-12-30') and date('2021-09-05')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('da4487e9-aaf6-ee29-0718-0e6b61ab9ebc','2eec5d6c-2cc6-cb11-3439-596e210dea5c') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='d85f8825-82dc-ff12-24c3-94e2967d22c0'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2019-12-30'))) as firstday , date(date_trunc('week',date('2021-08-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2019-12-30'::timestamp,'2021-09-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and (daydate > date('2021-09-05') or daydate < date('2019-12-30')) - OR (id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' AND daydate not between date('2019-12-30') and date('2021-09-05')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('d85f8825-82dc-ff12-24c3-94e2967d22c0','2eec5d6c-2cc6-cb11-3439-596e210dea5c') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2019-12-30'))) as firstday , date(date_trunc('week',date('2021-08-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2019-12-30'::timestamp,'2021-09-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and (daydate > date('2021-09-05') or daydate < date('2019-12-30')) - OR (id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' AND daydate not between date('2019-12-30') and date('2021-09-05')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1','2eec5d6c-2cc6-cb11-3439-596e210dea5c') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2019-12-30'))) as firstday , date(date_trunc('week',date('2021-08-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2019-12-30'::timestamp,'2021-09-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and (daydate > date('2021-09-05') or daydate < date('2019-12-30')) - OR (id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' AND daydate not between date('2019-12-30') and date('2021-09-05')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('a0538335-1f82-8312-8a62-2e42ea74ed20','2eec5d6c-2cc6-cb11-3439-596e210dea5c') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2019-12-30'))) as firstday , date(date_trunc('week',date('2021-08-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2019-12-30'::timestamp,'2021-09-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and (daydate > date('2021-09-05') or daydate < date('2019-12-30')) - OR (id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' AND daydate not between date('2019-12-30') and date('2021-09-05')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('ec6261df-f5df-d1b9-7ca1-639d79e82bfe','2eec5d6c-2cc6-cb11-3439-596e210dea5c') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2019-12-30'))) as firstday , date(date_trunc('week',date('2021-08-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2019-12-30'::timestamp,'2021-09-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and (daydate > date('2021-09-05') or daydate < date('2019-12-30')) - OR (id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' AND daydate not between date('2019-12-30') and date('2021-09-05')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('d1fe1b59-0129-bb85-53da-a4f9f69d9b83','2eec5d6c-2cc6-cb11-3439-596e210dea5c') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2019-12-30'))) as firstday , date(date_trunc('week',date('2021-08-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2019-12-30'::timestamp,'2021-09-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and (daydate > date('2021-09-05') or daydate < date('2019-12-30')) - OR (id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' AND daydate not between date('2019-12-30') and date('2021-09-05')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' group by rp.id); -EXEC: INSERT INTO kraeltgen.staffreportperiod (id_reportperiod, id_staff) - VALUES ('35fda5d9-36ef-528b-4339-286589719039','2eec5d6c-2cc6-cb11-3439-596e210dea5c') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select reportperiodunit,reportperiodlength from public.companies where schemata='kraeltgen' -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) scx where startdate < enddate and id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2020-01-01'),date('2020-02-29'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 44 as maxdays,44 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2020-01-01') and date('2020-02-29') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2020-02-29') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2020-02-29')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=44,contracthours='352:00:00' where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -QUERY: select * from kraeltgen.reportperiod where id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by rp.startdate,rp.enddate) - sper ) prp where id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-01-01'))) and date(date_trunc('week',date('2020-02-29')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-01-01'))) and date(date_trunc('week',date('2020-02-29')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-01-01') and date('2020-02-29') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and sr.daydate between date('2020-01-01') and date(date_trunc('week',date('2020-02-29')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-01-01'))) and date(date_trunc('week',date('2020-02-29')) + interval '6 days') - --where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2020-01-01') and date('2020-02-29') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=8,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2020-02-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '529236a0-bb8e-c0dd-6dfd-406fe2f59aff') - where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and pd.daydate between date('2020-01-01') and date('2020-02-29') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) scx where startdate < enddate and id='872690b5-74c8-6eb3-2c9c-2ad47ea57995' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2020-03-01'),date('2020-04-30'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 43 as maxdays,43 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2020-03-01') and date('2020-04-30') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2020-04-30') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2020-04-30')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=43,contracthours='344:00:00' where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod='872690b5-74c8-6eb3-2c9c-2ad47ea57995'; -QUERY: select * from kraeltgen.reportperiod where id='872690b5-74c8-6eb3-2c9c-2ad47ea57995'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by rp.startdate,rp.enddate) - sper ) prp where id='872690b5-74c8-6eb3-2c9c-2ad47ea57995'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-03-01'))) and date(date_trunc('week',date('2020-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-03-01'))) and date(date_trunc('week',date('2020-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='529236a0-bb8e-c0dd-6dfd-406fe2f59aff' and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,8+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-03-01') and date('2020-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-03-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,1+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and sr.daydate between date('2020-02-24') and date(date_trunc('week',date('2020-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-03-01'))) and date(date_trunc('week',date('2020-04-30')) + interval '6 days') - --where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2020-03-01') and date('2020-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=10,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2020-03-16'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '872690b5-74c8-6eb3-2c9c-2ad47ea57995') - where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and pd.daydate between date('2020-03-01') and date('2020-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) scx where startdate < enddate and id='c70d0d68-b69f-2b02-cec3-d82b47eca9b6' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2020-05-01'),date('2020-06-30'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 43 as maxdays,43 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2020-05-01') and date('2020-06-30') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2020-06-30') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2020-06-30')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=43,contracthours='344:00:00' where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod='c70d0d68-b69f-2b02-cec3-d82b47eca9b6'; -QUERY: select * from kraeltgen.reportperiod where id='c70d0d68-b69f-2b02-cec3-d82b47eca9b6'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by rp.startdate,rp.enddate) - sper ) prp where id='c70d0d68-b69f-2b02-cec3-d82b47eca9b6'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-05-01'))) and date(date_trunc('week',date('2020-06-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-05-01'))) and date(date_trunc('week',date('2020-06-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='872690b5-74c8-6eb3-2c9c-2ad47ea57995' and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,10+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-05-01') and date('2020-06-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,2+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and sr.daydate between date('2020-03-16') and date(date_trunc('week',date('2020-06-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-05-01'))) and date(date_trunc('week',date('2020-06-30')) + interval '6 days') - --where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2020-05-01') and date('2020-06-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'c70d0d68-b69f-2b02-cec3-d82b47eca9b6') - where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and pd.daydate between date('2020-05-01') and date('2020-06-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) scx where startdate < enddate and id='f9ed771d-6236-f6f3-caa7-e678a49023d0' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2020-07-01'),date('2020-08-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 45 as maxdays,45 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2020-07-01') and date('2020-08-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2020-08-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2020-08-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=45,contracthours='360:00:00' where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -QUERY: select * from kraeltgen.reportperiod where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by rp.startdate,rp.enddate) - sper ) prp where id='f9ed771d-6236-f6f3-caa7-e678a49023d0'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='c70d0d68-b69f-2b02-cec3-d82b47eca9b6' and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-07-01') and date('2020-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-07-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and sr.daydate between date('2020-07-01') and date(date_trunc('week',date('2020-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-07-01'))) and date(date_trunc('week',date('2020-08-31')) + interval '6 days') - --where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2020-07-01') and date('2020-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'f9ed771d-6236-f6f3-caa7-e678a49023d0') - where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and pd.daydate between date('2020-07-01') and date('2020-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) scx where startdate < enddate and id='1f489513-7b98-efb4-d16d-f3baeceb846a' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2020-09-01'),date('2020-10-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 44 as maxdays,44 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2020-09-01') and date('2020-10-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2020-10-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2020-10-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=44,contracthours='352:00:00' where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod='1f489513-7b98-efb4-d16d-f3baeceb846a'; -QUERY: select * from kraeltgen.reportperiod where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by rp.startdate,rp.enddate) - sper ) prp where id='1f489513-7b98-efb4-d16d-f3baeceb846a'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='f9ed771d-6236-f6f3-caa7-e678a49023d0' and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-09-01') and date('2020-10-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and sr.daydate between date('2020-09-01') and date(date_trunc('week',date('2020-10-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-09-01'))) and date(date_trunc('week',date('2020-10-31')) + interval '6 days') - --where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2020-09-01') and date('2020-10-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=7,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=4,last44date=date('2020-10-26'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '1f489513-7b98-efb4-d16d-f3baeceb846a') - where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and pd.daydate between date('2020-09-01') and date('2020-10-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) scx where startdate < enddate and id='83f75caf-b28e-5c31-cd74-d7a7bd23e960' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2020-11-01'),date('2020-12-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 43 as maxdays,43 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2020-11-01') and date('2020-12-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2020-12-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2020-12-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=43,contracthours='344:00:00' where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -QUERY: select * from kraeltgen.reportperiod where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by rp.startdate,rp.enddate) - sper ) prp where id='83f75caf-b28e-5c31-cd74-d7a7bd23e960'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='1f489513-7b98-efb4-d16d-f3baeceb846a' and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,7+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-11-01') and date('2020-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-11-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,4+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and sr.daydate between date('2020-10-26') and date(date_trunc('week',date('2020-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-11-01'))) and date(date_trunc('week',date('2020-12-31')) + interval '6 days') - --where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2020-11-01') and date('2020-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=8,suppvacancysunwork=null,suppvacancy44hours=1,status44hcount=4,last44date=date('2020-12-28'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '83f75caf-b28e-5c31-cd74-d7a7bd23e960') - where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and pd.daydate between date('2020-11-01') and date('2020-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) scx where startdate < enddate and id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-01-01'),date('2021-02-28'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 43 as maxdays,43 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2021-01-01') and date('2021-02-28') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-02-28') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-02-28')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=43,contracthours='344:00:00' where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -QUERY: select * from kraeltgen.reportperiod where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by rp.startdate,rp.enddate) - sper ) prp where id='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='83f75caf-b28e-5c31-cd74-d7a7bd23e960' and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,8+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-01-01') and date('2021-02-28') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,4+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and sr.daydate between date('2020-12-28') and date(date_trunc('week',date('2021-02-28')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-02-28')) + interval '6 days') - --where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2021-01-01') and date('2021-02-28') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=13,suppvacancysunwork=null,suppvacancy44hours=1,status44hcount=2,last44date=date('2021-02-22'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'da4487e9-aaf6-ee29-0718-0e6b61ab9ebc') - where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and pd.daydate between date('2021-01-01') and date('2021-02-28') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) scx where startdate < enddate and id='d85f8825-82dc-ff12-24c3-94e2967d22c0' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-03-01'),date('2021-04-30'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 43 as maxdays,43 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2021-03-01') and date('2021-04-30') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-04-30') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-04-30')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=43,contracthours='344:00:00' where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod='d85f8825-82dc-ff12-24c3-94e2967d22c0'; -QUERY: select * from kraeltgen.reportperiod where id='d85f8825-82dc-ff12-24c3-94e2967d22c0'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by rp.startdate,rp.enddate) - sper ) prp where id='d85f8825-82dc-ff12-24c3-94e2967d22c0'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2021-03-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2021-03-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='da4487e9-aaf6-ee29-0718-0e6b61ab9ebc' and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,13+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-03-01') and date('2021-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-03-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,2+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and sr.daydate between date('2021-02-22') and date(date_trunc('week',date('2021-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2021-03-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days') - --where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2021-03-01') and date('2021-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=15,suppvacancysunwork=null,suppvacancy44hours=1,status44hcount=2,last44date=date('2021-04-26'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'd85f8825-82dc-ff12-24c3-94e2967d22c0') - where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and pd.daydate between date('2021-03-01') and date('2021-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) scx where startdate < enddate and id='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-05-01'),date('2021-06-30'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 43 as maxdays,43 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2021-05-01') and date('2021-06-30') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-06-30') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-06-30')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=43,contracthours='344:00:00' where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1'; -QUERY: select * from kraeltgen.reportperiod where id='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by rp.startdate,rp.enddate) - sper ) prp where id='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-06-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-06-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='d85f8825-82dc-ff12-24c3-94e2967d22c0' and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,15+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-05-01') and date('2021-06-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,2+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and sr.daydate between date('2021-04-26') and date(date_trunc('week',date('2021-06-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-06-30')) + interval '6 days') - --where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2021-05-01') and date('2021-06-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=20,suppvacancysunwork=2,suppvacancy44hours=1,status44hcount=0,last44date=date('2021-06-28'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1') - where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and pd.daydate between date('2021-05-01') and date('2021-06-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) scx where startdate < enddate and id='a0538335-1f82-8312-8a62-2e42ea74ed20' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (1,2) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-07-01'),date('2021-08-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 44 as maxdays,44 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from kraeltgen.staffreportperioddays - where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2021-07-01') and date('2021-08-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-08-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-08-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from kraeltgen.staffcontract where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update kraeltgen.staffreportperiod set maxdays=44,contracthours='352:00:00' where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select * from kraeltgen.reportperiod where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by rp.startdate,rp.enddate) - sper ) prp where id='a0538335-1f82-8312-8a62-2e42ea74ed20'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from kraeltgen.staffreportperiod where id_reportperiod='f7f28bf3-b8c4-e1f1-2152-c253e23cc9a1' and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,20+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2021-07-01') and date('2021-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-07-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,0+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and sr.daydate between date('2021-06-28') and date(date_trunc('week',date('2021-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2021-07-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days') - --where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2021-07-01') and date('2021-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=26,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=4,last44date=date('2021-08-30'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a0538335-1f82-8312-8a62-2e42ea74ed20') - where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and pd.daydate between date('2021-07-01') and date('2021-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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 = '2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) scx where startdate < enddate and id='ec6261df-f5df-d1b9-7ca1-639d79e82bfe' order by startdate,enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) scx where startdate < enddate and id='d1fe1b59-0129-bb85-53da-a4f9f69d9b83' order by startdate,enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from kraeltgen.staffcontract sc - cross join kraeltgen.reportperiod rp - where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' - ) scx where startdate < enddate and id='35fda5d9-36ef-528b-4339-286589719039' order by startdate,enddate; -EXEC: insert into kraeltgen.staffvacancyyear (id_staff,vacyear) - select id_staff,to_char(daydate,'YYYY')::int4 as vyear from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' group by id_staff,vyear order by id_staff,vyear - on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from kraeltgen.reportperiod where id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='kraeltgen' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from kraeltgen.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff from kraeltgen.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2019-12-30'))) as firstday , date(date_trunc('week',date('2021-08-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into kraeltgen.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'2eec5d6c-2cc6-cb11-3439-596e210dea5c' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2019-12-30'::timestamp,'2021-09-05'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and (daydate > date('2021-09-05') or daydate < date('2019-12-30')) - OR (id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' AND daydate not between date('2019-12-30') and date('2021-09-05')); -EXEC: delete from kraeltgen.staffreportperiod sp where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod not in ( -select rp.id from kraeltgen.reportperiod rp left join kraeltgen.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' group by rp.id); -QUERY: select * from kraeltgen.reportperiod where id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from kraeltgen.staffreportperiod srp - join kraeltgen.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by rp.startdate,rp.enddate) - sper ) prp where id='529236a0-bb8e-c0dd-6dfd-406fe2f59aff'; -EXEC: update kraeltgen.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from kraeltgen.staffreportperioddays where id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-01-01'))) and date(date_trunc('week',date('2020-02-29')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update kraeltgen.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from kraeltgen.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from kraeltgen.staffreportperioddays where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-01-01'))) and date(date_trunc('week',date('2020-02-29')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from kraeltgen.staffreportperioddays -where daydate between date('2020-01-01') and date('2020-02-29') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from kraeltgen.staffreportperiod where id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and id_reportperiod in (select id from kraeltgen.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2020-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and sr.daydate between date('2020-01-01') and date(date_trunc('week',date('2020-02-29')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date(date_trunc('week',date('2020-01-01'))) and date(date_trunc('week',date('2020-02-29')) + interval '6 days') - --where id_staff= '2eec5d6c-2cc6-cb11-3439-596e210dea5c' and daydate between date('2020-01-01') and date('2020-02-29') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update kraeltgen.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=8,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2020-02-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 kraeltgen.staffreportperioddays pd - join kraeltgen.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '529236a0-bb8e-c0dd-6dfd-406fe2f59aff') - where pd.id_staff='2eec5d6c-2cc6-cb11-3439-596e210dea5c' and pd.daydate between date('2020-01-01') and date('2020-02-29') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from kraeltgen.reportperiod where id='35fda5d9-36ef-528b-4339-286589719039' -QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff - ,to_char(ws.workhours::interval,'HH24:MI') as workhours - ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal - ,to_char(ws.vacillhours,'HH24:MI') as vacancyill - ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra - ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours - ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours - ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours - ,to_char(ws.totalhours,'HH24:MI') as totalhours - ,cd.contractworkdays - ,cd.cmpcontractdays - ,cd.cmpweekhours - ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours - ,ws.periodworkhours - ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff - ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours - ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff - ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours - ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours - ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours - ,case when cd.contractworkdays < cd.cmpcontractdays then - to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI') - else - to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI') - end as maxweekhours - ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else - to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI') - end as defaultweekhours - from ( - SELECT weekstart,weekend,calweek,calyear, id_staff, - sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours, - sum(case when srpd.daydate between date('2022-01-01') and date('2022-06-30') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours, - --sum(case when srpd.daydate between date('2022-01-01') and date('2022-06-30') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause, - sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours, - sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours, - sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours, - sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours, - sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours, - sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours, - sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours, - sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays, - sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from kraeltgen.staffreportperioddays - where id_staff= 'e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2021-12-27') and date('2022-07-03') - ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff - ORDER BY weekstart) ws left join ( - select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours, - case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays, - case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays - from ( select id_staff,weekdays ,weekhours, - case when startdate> date('2021-12-27') then startdate else date('2021-12-27') end as staffperiodstart, - case when enddate is null or enddate > date('2022-07-03') then date('2022-07-03') - else enddate end as staffperiodend from kraeltgen.staffcontract where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' - and startdate < date('2022-07-03') - ) sc - join kraeltgen.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend) - group by date(date_trunc('week',pd.daydate)),pd.id_staff - ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart - left join ( - select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from ( - select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate, - case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours , - case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours - from kraeltgen.staffreportperioddays lpd - left join kraeltgen.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate) - cross join (select * from kraeltgen.worktimes where isdefault=true) wkdef - where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and lpd.daydate between date('2021-12-27') and date('2022-07-03') - order by lpd.daydate ) mh group by id_staff,weekstart - ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart - left join ( - select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from ( - select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from ( -select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from kraeltgen.timetracker -where daydate between date('2022-01-01') and date('2022-06-30') and id_staff ='e3ed2959-a411-2f14-b40a-27251d8f6d0c') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff - ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment, - vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment, - date(date_trunc('week',pd.daydate)) as weekstart, - to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1, - to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1, - to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2, - to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2, - to_char(pd.timepause::interval, 'HH24:MI') AS timepause, - -- coalesce('
' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '
','') AS dspvacancyhours, - to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours, - to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours, - to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours, - to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours, - to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours, - to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours, - to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours, - to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours, - to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours, - to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours, - to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours, - to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1, - to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1, - to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2, - to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2, - COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata, - COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata, - CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter, - to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours, - to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours, - to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation, - to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours, - max(vd.vacancyname) as vacancyname, - to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime, - interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff, - max(tt.incompletetrack) as incompletetrack - FROM kraeltgen.staffreportperioddays pd - JOIN kraeltgen.staff st ON pd.id_staff = st.id and st.id='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and st.isdeleted is null - LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto, - yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval, - date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM kraeltgen.staffreportperioddays sr - WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate - left join kraeltgen.worktimes wk on pd.daydate between wk.startdate and wk.enddate - cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from kraeltgen.worktimes where isdefault =true) wkstd - left join kraeltgen.vacancydays vd on pd.daydate=vd.daydate - left join ( - select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime, - sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack -from kraeltgen.timetracker where id_staff='e3ed2959-a411-2f14-b40a-27251d8f6d0c' and daydate between date('2021-12-27') and date('2022-07-03') group by daydate - ) tt on pd.daydate=tt.daydate - WHERE pd.daydate between date('2021-12-27') and date('2022-07-03') - group by pd.id - ORDER BY pd.id_staff, pd.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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_reportperiod = '35fda5d9-36ef-528b-4339-286589719039' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - 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_reportperiod = '529236a0-bb8e-c0dd-6dfd-406fe2f59aff' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: 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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select sessiondata from public.sessions where id='6cfa9047-f585-a84b-62b0-0e0a53c9fd08' -EXEC: update public.sessions set sessiondata='{"schemata":"lousdiner"}' where id='6cfa9047-f585-a84b-62b0-0e0a53c9fd08' -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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.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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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 lousdiner.staffgroups sg LEFT JOIN lousdiner.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(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' AS staffname,sc.staffstatus from lousdiner.staff st -LEFT JOIN lousdiner.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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from lousdiner.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='lousdiner') ttr -where st.isdeleted is null order by groupname,st.staffnumber,surname,prename; -QUERYARRAY: select id,trackername from lousdiner.timetrackerconfig order by trackername -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 lousdiner.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from lousdiner.staff where id='ae108794-eb2b-836d-7348-50f30bea5204' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from lousdiner.staffcontract where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by startdate,enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from lousdiner.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from lousdiner.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join lousdiner.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - join lousdiner.staff st on (pd.id_staff=st.id) - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ae108794-eb2b-836d-7348-50f30bea5204' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ae108794-eb2b-836d-7348-50f30bea5204' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from lousdiner.staffreportperioddays spd - join lousdiner.staff st on (st.id=spd.id_staff) - join lousdiner.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from lousdiner.staffvacancyyear where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by vacyear; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from lousdiner.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from lousdiner.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join lousdiner.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - join lousdiner.staff st on (pd.id_staff=st.id) - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ae108794-eb2b-836d-7348-50f30bea5204' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ae108794-eb2b-836d-7348-50f30bea5204' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7' -QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff - ,to_char(ws.workhours::interval,'HH24:MI') as workhours - ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal - ,to_char(ws.vacillhours,'HH24:MI') as vacancyill - ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra - ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours - ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours - ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours - ,to_char(ws.totalhours,'HH24:MI') as totalhours - ,cd.contractworkdays - ,cd.cmpcontractdays - ,cd.cmpweekhours - ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours - ,ws.periodworkhours - ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff - ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours - ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff - ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours - ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours - ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours - ,case when cd.contractworkdays < cd.cmpcontractdays then - to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI') - else - to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI') - end as maxweekhours - ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else - to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI') - end as defaultweekhours - from ( - SELECT weekstart,weekend,calweek,calyear, id_staff, - sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours, - sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours, - --sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause, - sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours, - sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours, - sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours, - sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours, - sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours, - sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours, - sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours, - sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays, - sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date('2021-02-01') and date('2021-08-01') - ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff - ORDER BY weekstart) ws left join ( - select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours, - case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays, - case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays - from ( select id_staff,weekdays ,weekhours, - case when startdate> date('2021-02-01') then startdate else date('2021-02-01') end as staffperiodstart, - case when enddate is null or enddate > date('2021-08-01') then date('2021-08-01') - else enddate end as staffperiodend from lousdiner.staffcontract where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' - and startdate < date('2021-08-01') - ) sc - join lousdiner.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend) - group by date(date_trunc('week',pd.daydate)),pd.id_staff - ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart - left join ( - select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from ( - select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate, - case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours , - case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours - from lousdiner.staffreportperioddays lpd - left join lousdiner.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate) - cross join (select * from lousdiner.worktimes where isdefault=true) wkdef - where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and lpd.daydate between date('2021-02-01') and date('2021-08-01') - order by lpd.daydate ) mh group by id_staff,weekstart - ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart - left join ( - select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from ( - select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from ( -select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from lousdiner.timetracker -where daydate between date('2021-02-01') and date('2021-07-31') and id_staff ='ae108794-eb2b-836d-7348-50f30bea5204') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff - ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment, - vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment, - date(date_trunc('week',pd.daydate)) as weekstart, - to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1, - to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1, - to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2, - to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2, - to_char(pd.timepause::interval, 'HH24:MI') AS timepause, - -- coalesce('
' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '
','') AS dspvacancyhours, - to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours, - to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours, - to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours, - to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours, - to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours, - to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours, - to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours, - to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours, - to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours, - to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours, - to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours, - to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1, - to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1, - to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2, - to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2, - COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata, - COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata, - CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter, - to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours, - to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours, - to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation, - to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours, - max(vd.vacancyname) as vacancyname, - to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime, - interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff, - max(tt.incompletetrack) as incompletetrack - FROM lousdiner.staffreportperioddays pd - JOIN lousdiner.staff st ON pd.id_staff = st.id and st.id='ae108794-eb2b-836d-7348-50f30bea5204' and st.isdeleted is null - LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto, - yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval, - date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate - left join lousdiner.worktimes wk on pd.daydate between wk.startdate and wk.enddate - cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from lousdiner.worktimes where isdefault =true) wkstd - left join lousdiner.vacancydays vd on pd.daydate=vd.daydate - left join ( - select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime, - sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack -from lousdiner.timetracker where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date('2021-02-01') and date('2021-08-01') group by daydate - ) tt on pd.daydate=tt.daydate - WHERE pd.daydate between date('2021-02-01') and date('2021-08-01') - group by pd.id - ORDER BY pd.id_staff, pd.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from lousdiner.staffreportperioddays where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate < date('2021-02-01') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1; -QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7' -QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from lousdiner.staffreportperioddays where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate > date('2021-02-01') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1; -QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff - ,to_char(ws.workhours::interval,'HH24:MI') as workhours - ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal - ,to_char(ws.vacillhours,'HH24:MI') as vacancyill - ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra - ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours - ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours - ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours - ,to_char(ws.totalhours,'HH24:MI') as totalhours - ,cd.contractworkdays - ,cd.cmpcontractdays - ,cd.cmpweekhours - ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours - ,ws.periodworkhours - ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff - ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours - ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff - ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours - ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours - ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours - ,case when cd.contractworkdays < cd.cmpcontractdays then - to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI') - else - to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI') - end as maxweekhours - ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else - to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI') - end as defaultweekhours - from ( - SELECT weekstart,weekend,calweek,calyear, id_staff, - sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours, - sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours, - --sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause, - sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours, - sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours, - sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours, - sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours, - sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours, - sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours, - sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours, - sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays, - sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date('2021-02-01') and date('2021-08-01') - ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff - ORDER BY weekstart) ws left join ( - select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours, - case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays, - case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays - from ( select id_staff,weekdays ,weekhours, - case when startdate> date('2021-02-01') then startdate else date('2021-02-01') end as staffperiodstart, - case when enddate is null or enddate > date('2021-08-01') then date('2021-08-01') - else enddate end as staffperiodend from lousdiner.staffcontract where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' - and startdate < date('2021-08-01') - ) sc - join lousdiner.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend) - group by date(date_trunc('week',pd.daydate)),pd.id_staff - ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart - left join ( - select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from ( - select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate, - case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours , - case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours - from lousdiner.staffreportperioddays lpd - left join lousdiner.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate) - cross join (select * from lousdiner.worktimes where isdefault=true) wkdef - where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and lpd.daydate between date('2021-02-01') and date('2021-08-01') - order by lpd.daydate ) mh group by id_staff,weekstart - ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart - left join ( - select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from ( - select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from ( -select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from lousdiner.timetracker -where daydate between date('2021-02-01') and date('2021-07-31') and id_staff ='ae108794-eb2b-836d-7348-50f30bea5204') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff - ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff; -QUERY: select weekhours from lousdiner.staffcontract where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and ((date('2021-02-01') between startdate and enddate) or (startdate <= date('2021-02-01') and enddate is null)) order by startdate,enddate nulls first limit 1; -QUERY: select to_char(wk.maxdayhours,'HH24:MI') as maxdayhours, - to_char(wk.maxweekhours,'HH24:MI') as maxweekhours, - to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours, - to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation, - to_char(wk.defaultweekhours,'HH24:MI') as defaultweekhours, - '' as datebefore, - '' as timebefore, - '' as dateafter, - '' as timeafter - from lousdiner.worktimes wk where (date('2021-02-01') between wk.startdate and wk.enddate) or (wk.startdate is null and wk.enddate is null) and maxhourspercents is null - order by wk.startdate,wk.enddate nulls last limit 1; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment, - vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment, - date(date_trunc('week',pd.daydate)) as weekstart, - to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1, - to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1, - to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2, - to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2, - to_char(pd.timepause::interval, 'HH24:MI') AS timepause, - -- coalesce('
' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '
','') AS dspvacancyhours, - to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours, - to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours, - to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours, - to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours, - to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours, - to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours, - to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours, - to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours, - to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours, - to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours, - to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours, - to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1, - to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1, - to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2, - to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2, - COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata, - COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata, - CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter, - to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours, - to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours, - to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation, - to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours, - max(vd.vacancyname) as vacancyname, - to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime, - interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff, - max(tt.incompletetrack) as incompletetrack - FROM lousdiner.staffreportperioddays pd - JOIN lousdiner.staff st ON pd.id_staff = st.id and st.id='ae108794-eb2b-836d-7348-50f30bea5204' and st.isdeleted is null - LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto, - yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval, - date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate - left join lousdiner.worktimes wk on pd.daydate between wk.startdate and wk.enddate - cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from lousdiner.worktimes where isdefault =true) wkstd - left join lousdiner.vacancydays vd on pd.daydate=vd.daydate - left join ( - select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime, - sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack -from lousdiner.timetracker where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date('2021-02-01') and date('2021-08-01') group by daydate - ) tt on pd.daydate=tt.daydate - WHERE pd.daydate between date('2021-02-01') and date('2021-08-01') - group by pd.id - ORDER BY pd.id_staff, pd.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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 lousdiner.staffgroups sg LEFT JOIN lousdiner.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(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' AS staffname,sc.staffstatus from lousdiner.staff st -LEFT JOIN lousdiner.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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from lousdiner.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='lousdiner') ttr -where st.isdeleted is null order by groupname,st.staffnumber,surname,prename; -QUERYARRAY: select id,trackername from lousdiner.timetrackerconfig order by trackername -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 lousdiner.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from lousdiner.staff where id='ae108794-eb2b-836d-7348-50f30bea5204' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from lousdiner.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from lousdiner.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join lousdiner.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - join lousdiner.staff st on (pd.id_staff=st.id) - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ae108794-eb2b-836d-7348-50f30bea5204' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from lousdiner.staffreportperioddays spd - join lousdiner.staff st on (st.id=spd.id_staff) - join lousdiner.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ae108794-eb2b-836d-7348-50f30bea5204' - 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 lousdiner.staffvacancyyear where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' 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 lousdiner.staffcontract where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from lousdiner.staff where id='ae108794-eb2b-836d-7348-50f30bea5204' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from lousdiner.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from lousdiner.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join lousdiner.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - join lousdiner.staff st on (pd.id_staff=st.id) - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ae108794-eb2b-836d-7348-50f30bea5204' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ae108794-eb2b-836d-7348-50f30bea5204' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from lousdiner.staffcontract where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from lousdiner.staffvacancyyear where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by vacyear; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from lousdiner.staffreportperioddays spd - join lousdiner.staff st on (st.id=spd.id_staff) - join lousdiner.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from lousdiner.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from lousdiner.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join lousdiner.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - join lousdiner.staff st on (pd.id_staff=st.id) - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ae108794-eb2b-836d-7348-50f30bea5204' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ae108794-eb2b-836d-7348-50f30bea5204' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7' -QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff - ,to_char(ws.workhours::interval,'HH24:MI') as workhours - ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal - ,to_char(ws.vacillhours,'HH24:MI') as vacancyill - ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra - ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours - ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours - ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours - ,to_char(ws.totalhours,'HH24:MI') as totalhours - ,cd.contractworkdays - ,cd.cmpcontractdays - ,cd.cmpweekhours - ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours - ,ws.periodworkhours - ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff - ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours - ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff - ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours - ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours - ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours - ,case when cd.contractworkdays < cd.cmpcontractdays then - to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI') - else - to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI') - end as maxweekhours - ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else - to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI') - end as defaultweekhours - from ( - SELECT weekstart,weekend,calweek,calyear, id_staff, - sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours, - sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours, - --sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause, - sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours, - sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours, - sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours, - sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours, - sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours, - sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours, - sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours, - sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays, - sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date('2021-02-01') and date('2021-08-01') - ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff - ORDER BY weekstart) ws left join ( - select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours, - case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays, - case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays - from ( select id_staff,weekdays ,weekhours, - case when startdate> date('2021-02-01') then startdate else date('2021-02-01') end as staffperiodstart, - case when enddate is null or enddate > date('2021-08-01') then date('2021-08-01') - else enddate end as staffperiodend from lousdiner.staffcontract where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' - and startdate < date('2021-08-01') - ) sc - join lousdiner.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend) - group by date(date_trunc('week',pd.daydate)),pd.id_staff - ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart - left join ( - select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from ( - select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate, - case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours , - case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours - from lousdiner.staffreportperioddays lpd - left join lousdiner.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate) - cross join (select * from lousdiner.worktimes where isdefault=true) wkdef - where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and lpd.daydate between date('2021-02-01') and date('2021-08-01') - order by lpd.daydate ) mh group by id_staff,weekstart - ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart - left join ( - select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from ( - select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from ( -select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from lousdiner.timetracker -where daydate between date('2021-02-01') and date('2021-07-31') and id_staff ='ae108794-eb2b-836d-7348-50f30bea5204') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff - ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment, - vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment, - date(date_trunc('week',pd.daydate)) as weekstart, - to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1, - to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1, - to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2, - to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2, - to_char(pd.timepause::interval, 'HH24:MI') AS timepause, - -- coalesce('
' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '
','') AS dspvacancyhours, - to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours, - to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours, - to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours, - to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours, - to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours, - to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours, - to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours, - to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours, - to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours, - to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours, - to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours, - to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1, - to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1, - to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2, - to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2, - COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata, - COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata, - CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter, - to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours, - to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours, - to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation, - to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours, - max(vd.vacancyname) as vacancyname, - to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime, - interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff, - max(tt.incompletetrack) as incompletetrack - FROM lousdiner.staffreportperioddays pd - JOIN lousdiner.staff st ON pd.id_staff = st.id and st.id='ae108794-eb2b-836d-7348-50f30bea5204' and st.isdeleted is null - LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto, - yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval, - date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate - left join lousdiner.worktimes wk on pd.daydate between wk.startdate and wk.enddate - cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from lousdiner.worktimes where isdefault =true) wkstd - left join lousdiner.vacancydays vd on pd.daydate=vd.daydate - left join ( - select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime, - sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack -from lousdiner.timetracker where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date('2021-02-01') and date('2021-08-01') group by daydate - ) tt on pd.daydate=tt.daydate - WHERE pd.daydate between date('2021-02-01') and date('2021-08-01') - group by pd.id - ORDER BY pd.id_staff, pd.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select date(date_trunc('week',startdate)) as startdate,startdate as periodstart, enddate as periodend,date(date_trunc('week',enddate) + interval '6 days') as enddate from lousdiner.reportperiod where id='bec92b1d-4b99-4aad-ddcb-a693b929acd7' -QUERY: select daydate as datebefore,to_char(case when timestart2 is null then timeend1 else timeend2 end,'HH24:MI') as timeendbefore from lousdiner.staffreportperioddays where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate < date('2021-02-01') and (timestart1 is not null or timestart2 is not null) order by daydate desc limit 1; -QUERYBYKEY: select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff - ,to_char(ws.workhours::interval,'HH24:MI') as workhours - ,to_char(ws.vacancyhours,'HH24:MI') as vacancynormal - ,to_char(ws.vacillhours,'HH24:MI') as vacancyill - ,to_char(ws.vacextrahours,'HH24:MI') as vacancyextra - ,to_char(ws.otherpaidhours,'HH24:MI') as otherpaidhours - ,to_char(ws.partunemplhours,'HH24:MI') as partunemplhours - ,to_char(ws.recuperationhours,'HH24:MI') as recuperationhours - ,to_char(ws.totalhours,'HH24:MI') as totalhours - ,cd.contractworkdays - ,cd.cmpcontractdays - ,cd.cmpweekhours - ,to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval),'HH24:MI') as weektrackedhours - ,ws.periodworkhours - ,interval_to_char(sum(coalesce(ttr.weektrackedhours,'00:00:00'::interval)) over (order by ws.weekstart) - sum(ws.periodworkhours::interval) over (order by ws.weekstart)) as periodtrackdiff - ,sum(ws.workhours::interval) over (order by ws.weekstart) as runningworkhours - ,interval_to_char(coalesce(ttr.weektrackedhours,'00:00:00'::interval) - ws.periodworkhours::interval) as trackeddiff - ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else to_char(cd.contracthours,'HH24:MI') end as contracthours - ,to_char(AVG(ws.totalhours) over (order by ws.weekstart),'HH24:MI') as avgtotalhours - ,case when cd.contractworkdays < cd.cmpcontractdays then '00:00' else interval_to_char(ws.totalhours-cd.contracthours) end as diffhours - ,case when cd.contractworkdays < cd.cmpcontractdays then - to_char(case when cd.cmpweekhours < '40:00:00'::interval then cd.contracthours * 1.15 * cd.contractworkdays else (cd.contractworkdays*'08:00:00'::interval) + (cd.contractworkdays* case when maxdata.maxweekhours > '48:00:00' then '01:16:50'::interval else '00:50:00'::interval end) end,'HH24:MI') - else - to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours * 1.15 else maxdata.maxweekhours end,'HH24:MI') - end as maxweekhours - ,case when cd.contractworkdays < cd.cmpcontractdays then to_char(cd.contractworkdays*'08:00:00'::interval,'HH24:MI') else - to_char(case when cd.contracthours < '40:00:00'::interval then cd.contracthours else maxdata.defaultweekhours end,'HH24:MI') - end as defaultweekhours - from ( - SELECT weekstart,weekend,calweek,calyear, id_staff, - sum(CASE WHEN srpd.workhours IS NULL THEN '00:00:00'::interval ELSE srpd.workhours::interval END) AS workhours, - sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhours, - --sum(case when srpd.daydate between date('2021-02-01') and date('2021-07-31') then coalesce(srpd.workhours::interval, '00:00:00'::interval) else '00:00:00'::interval end) as periodworkhoursnopause, - sum(CASE WHEN srpd.vacancyhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacancyhours::interval END) AS vacancyhours, - sum(CASE WHEN srpd.vacillhours IS NULL THEN '00:00:00'::interval ELSE srpd.vacillhours::interval END) AS vacillhours, - sum(CASE WHEN srpd.vacextrahours IS NULL THEN '00:00:00'::interval ELSE srpd.vacextrahours::interval END) AS vacextrahours, - sum(CASE WHEN srpd.recuperationhours IS NULL THEN '00:00:00'::interval ELSE srpd.recuperationhours::interval END) AS recuperationhours, - sum(CASE WHEN srpd.otherpaidhours IS NULL THEN '00:00:00'::interval ELSE srpd.otherpaidhours::interval END) AS otherpaidhours, - sum(CASE WHEN srpd.partunemplhours IS NULL THEN '00:00:00'::interval ELSE srpd.partunemplhours::interval END) AS partunemplhours, - sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours, - sum(CASE WHEN srpd.workhours > '00:00:00'::time without time zone OR srpd.recuperationhours > '00:00:00'::time without time zone OR srpd.vacancyhours > '00:00:00'::time without time zone OR srpd.vacillhours > '00:00:00'::time without time zone OR srpd.vacextrahours > '00:00:00'::time without time zone OR srpd.otherpaidhours > '00:00:00'::time without time zone or srpd.partunemplhours > '00:00:00'::time without time zone THEN 1 ELSE 0 END) AS workdays, - sum( CASE WHEN srpd.contracthours IS NULL THEN '00:00:00'::interval ELSE srpd.contracthours::interval END) AS contracthours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from lousdiner.staffreportperioddays - where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date('2021-02-01') and date('2021-08-01') - ) srpd GROUP BY srpd.weekstart,srpd.weekend,srpd.calweek,srpd.calyear,srpd.id_staff - ORDER BY weekstart) ws left join ( - select date(date_trunc('week',pd.daydate)) as weekstart,pd.id_staff,max(sc.weekdays) as cmpcontractdays,max(sc.weekhours) as cmpweekhours, - case when count(pd.daydate) < avg(sc.weekdays) then count(pd.daydate) else avg(sc.weekdays) end as contractworkdays, - case when count(pd.daydate) < avg(sc.weekdays) then avg(sc.weekhours/ sc.weekdays) * count(pd.daydate) else avg(sc.weekhours/ sc.weekdays) * avg(sc.weekdays) end as contracthours ,sum(case when coalesce(pd.workhours,'00:00:00'::time) > '00:00:00'::time then 1 else 0 end) as realworkdays - from ( select id_staff,weekdays ,weekhours, - case when startdate> date('2021-02-01') then startdate else date('2021-02-01') end as staffperiodstart, - case when enddate is null or enddate > date('2021-08-01') then date('2021-08-01') - else enddate end as staffperiodend from lousdiner.staffcontract where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' - and startdate < date('2021-08-01') - ) sc - join lousdiner.staffreportperioddays pd on (pd.id_staff=sc.id_staff and pd.daydate between sc.staffperiodstart and sc.staffperiodend) - group by date(date_trunc('week',pd.daydate)),pd.id_staff - ) cd on ws.id_staff = cd.id_staff and ws.weekstart=cd.weekstart - left join ( - select id_staff,weekstart,max(defaultweekhours) as defaultweekhours,avg(maxweekhours) as maxweekhours from ( - select lpd.id_staff,date(date_trunc('week',lpd.daydate)) as weekstart,lpd.daydate, - case when wk.defaultweekhours is null then wkdef.defaultweekhours else wk.defaultweekhours end as defaultweekhours , - case when wk.maxweekhours is null then wkdef.maxweekhours else wk.maxweekhours end as maxweekhours - from lousdiner.staffreportperioddays lpd - left join lousdiner.worktimes wk on (lpd.daydate between wk.startdate and wk.enddate) - cross join (select * from lousdiner.worktimes where isdefault=true) wkdef - where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and lpd.daydate between date('2021-02-01') and date('2021-08-01') - order by lpd.daydate ) mh group by id_staff,weekstart - ) maxdata on ws.id_staff = maxdata.id_staff and ws.weekstart=maxdata.weekstart - left join ( - select weekstart,id_staff,coalesce(sum(daytracked),'00:00:00'::interval) as weektrackedhours from ( - select daydate,id_staff,weekstart,case when sum(trackedhours) > '06:00:00'::interval then sum(trackedhours)- '00:30:00'::interval else coalesce(sum(trackedhours),'00:00:00'::interval) end as daytracked from ( -select daydate,date(date_trunc('week',daydate)) as weekstart,id_staff,(stamp_out-stamp_in)::interval as trackedhours from lousdiner.timetracker -where daydate between date('2021-02-01') and date('2021-07-31') and id_staff ='ae108794-eb2b-836d-7348-50f30bea5204') tto group by daydate,id_staff,weekstart,trackedhours) ttx group by weekstart,id_staff - ) ttr on ws.weekstart=ttr.weekstart and ws.id_staff=ttr.id_staff; -QUERY: select daydate as dateafter ,to_char(case when timestart1 is null then timestart2 else timestart1 end,'HH24:MI') as timestartafter from lousdiner.staffreportperioddays where id_staff= 'ae108794-eb2b-836d-7348-50f30bea5204' and daydate > date('2021-02-01') and (timestart1 is not null or timestart2 is not null) order by daydate asc limit 1; -QUERY: select weekhours from lousdiner.staffcontract where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and ((date('2021-02-01') between startdate and enddate) or (startdate <= date('2021-02-01') and enddate is null)) order by startdate,enddate nulls first limit 1; -QUERY: select to_char(wk.maxdayhours,'HH24:MI') as maxdayhours, - to_char(wk.maxweekhours,'HH24:MI') as maxweekhours, - to_char(wk.maxinterruptionhours,'HH24:MI') as maxinterruptionhours, - to_char(wk.mindailyrecuperation,'HH24:MI') as mindailyrecuperation, - to_char(wk.defaultweekhours,'HH24:MI') as defaultweekhours, - '' as datebefore, - '' as timebefore, - '' as dateafter, - '' as timeafter - from lousdiner.worktimes wk where (date('2021-02-01') between wk.startdate and wk.enddate) or (wk.startdate is null and wk.enddate is null) and maxhourspercents is null - order by wk.startdate,wk.enddate nulls last limit 1; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT pd.id,pd.id_staff,pd.id_reportperiod,pd.daydate,pd.payedpause,pd.daytype,pd.daycomment, - vacancycomment,vacillcomment,vacextracomment,recupcomment,otherpaidhourscomment,partunempcomment, - date(date_trunc('week',pd.daydate)) as weekstart, - to_char(pd.timestart1::interval, 'HH24:MI') AS timestart1, - to_char(pd.timeend1::interval, 'HH24:MI') AS timeend1, - to_char(pd.timestart2::interval, 'HH24:MI') AS timestart2, - to_char(pd.timeend2::interval, 'HH24:MI') AS timeend2, - to_char(pd.timepause::interval, 'HH24:MI') AS timepause, - -- coalesce('
' || to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN null ELSE pd.vacancyhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN null else pd.vacillhours END::interval, 'HH24:MI') || '
','') || - -- coalesce('
' || to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN null ELSE pd.vacextrahours END::interval, 'HH24:MI') || '
','') AS dspvacancyhours, - to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours, - to_char(CASE WHEN pd.vacillhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacillhours END::interval, 'HH24:MI') AS vacillhours, - to_char(CASE WHEN pd.vacextrahours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacextrahours END::interval, 'HH24:MI') AS vacextrahours, - to_char(CASE WHEN pd.otherpaidhours::interval = '00:00:00'::interval THEN NULL ELSE pd.otherpaidhours END::interval, 'HH24:MI') AS otherpaidhours, - to_char(CASE WHEN pd.partunemplhours::interval = '00:00:00'::interval THEN NULL ELSE pd.partunemplhours END::interval, 'HH24:MI') AS partunemplhours, - to_char(pd.contracthours::interval, 'HH24:MI') AS contracthours, - to_char(CASE WHEN pd.workhours::interval = '00:00:00'::interval THEN NULL ELSE pd.workhours END::interval, 'HH24:MI') AS workhours, - to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours, - to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours, - to_char(CASE WHEN pd.interruptionhours::interval = '00:00:00'::interval THEN NULL ELSE pd.interruptionhours END::interval, 'HH24:MI') AS interruptionhours, - to_char(CASE WHEN pd.nighthours::interval = '00:00:00'::interval THEN NULL ELSE pd.nighthours END::interval, 'HH24:MI') AS nighthours, - to_char(pd.pausestart1::interval, 'HH24:MI') AS pausestart1, - to_char(pd.pauseend1::interval, 'HH24:MI') AS pauseend1, - to_char(pd.pausestart2::interval, 'HH24:MI') AS pausestart2, - to_char(pd.pauseend2::interval, 'HH24:MI') AS pauseend2, - COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata, - COALESCE((to_char(pd.timestart1::interval, 'HH24:MI') || '-') || to_char(pd.timeend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.timestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.timestart2::interval, 'HH24:MI')) || '-') || to_char(pd.timeend2::interval, 'HH24:MI'), '') AS dspworkdata, - CASE WHEN max(freehours.freehours) < '00:00:00'::interval THEN NULL ELSE to_char(max(freehours.freehours), 'HH24:MI') END AS freehoursafter, - to_char(coalesce(max(wk.defaultdayhours),max(wkstd.defaultdayhours)),'HH24:MI') as defaultdayhours, - to_char(coalesce(max(wk.maxdayhours),max(wkstd.maxdayhours)),'HH24:MI') as maxdayhours, - to_char(coalesce(max(wk.mindailyrecuperation),max(wkstd.mindailyrecuperation)),'HH24:MI') as mindailyrecuperation, - to_char(coalesce(max(wk.maxinterruptionhours),max(wkstd.maxinterruptionhours)),'HH24:MI') as maxinterruptionhours, - max(vd.vacancyname) as vacancyname, - to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end,'HH24:MI') as trackedtime, - interval_to_char(case when (max(tt.trackedtime) >= '06:00:00'::interval) then max(tt.trackedtime) - case when pd.timepause::interval > '00:30:00'::interval then pd.timepause::interval else '00:30:00'::interval end else max(tt.trackedtime) end - coalesce(pd.workhours::interval,'00:00:00'::interval)) as trackeddiff, - max(tt.incompletetrack) as incompletetrack - FROM lousdiner.staffreportperioddays pd - JOIN lousdiner.staff st ON pd.id_staff = st.id and st.id='ae108794-eb2b-836d-7348-50f30bea5204' and st.isdeleted is null - LEFT JOIN ( SELECT yy.id_staff, yy.ndaydate AS daydate,yy.ndaydate + yy.ntimeend AS tmfrom, yy.daydate + yy.timestart AS tmto, - yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend) AS realinterval, - date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval AS freehours - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM lousdiner.staffreportperioddays sr - WHERE sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy) freehours ON pd.id_staff = freehours.id_staff AND freehours.daydate = pd.daydate - left join lousdiner.worktimes wk on pd.daydate between wk.startdate and wk.enddate - cross join (select defaultdayhours,maxdayhours,mindailyrecuperation,maxinterruptionhours from lousdiner.worktimes where isdefault =true) wkstd - left join lousdiner.vacancydays vd on pd.daydate=vd.daydate - left join ( - select daydate,sum(case when stamp_out is not null then cast(stamp_out-stamp_in as interval)::interval else '00:00:00'::interval end) as trackedtime, - sum(case when stamp_out is null and daydate < current_date then 1 else 0 end) as incompletetrack -from lousdiner.timetracker where id_staff='ae108794-eb2b-836d-7348-50f30bea5204' and daydate between date('2021-02-01') and date('2021-08-01') group by daydate - ) tt on pd.daydate=tt.daydate - WHERE pd.daydate between date('2021-02-01') and date('2021-08-01') - group by pd.id - ORDER BY pd.id_staff, pd.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,daydate,to_char(stamp_in,'HH24:MI') as stamp_in,to_char(stamp_out,'HH24:MI') as stamp_out, -case when stamp_in is null or stamp_out is null then '00:00' else to_char(stamp_out-stamp_in,'HH24:MI') end as total -from lousdiner.timetracker where daydate=date('2021-02-01') and id_staff='ae108794-eb2b-836d-7348-50f30bea5204' order by stamp_in,stamp_out; -QUERYARRAY: select public.getuuid() as id, 'ae108794-eb2b-836d-7348-50f30bea5204' as id_staff,date('2021-02-01') as daydate,'00:00' as stamp_in,'00:00' as stamp_out, '00:00' as total -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from lousdiner.staff where id='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from lousdiner.staffvacancyyear where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' order by vacyear; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from lousdiner.staffreportperioddays spd - join lousdiner.staff st on (st.id=spd.id_staff) - join lousdiner.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from lousdiner.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from lousdiner.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join lousdiner.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join lousdiner.reportperiod rp on (rp.id=srp.id_reportperiod) - join lousdiner.staff st on (pd.id_staff=st.id) - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from lousdiner.staffcontract where id_staff='ef90b898-96ad-f5f1-b0b9-ad9a4d95320b' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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.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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from lousdiner.staffreportperioddays spd - join lousdiner.staff st on (st.id=spd.id_staff) - join lousdiner.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and date_trunc('year',spd.daydate)=date_trunc('year',date('2022-01-01')) - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: 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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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 lousdiner.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 lousdiner.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = 'bec92b1d-4b99-4aad-ddcb-a693b929acd7' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = '6748aadc-7171-bc73-a0b3-e097b8fa8716' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM lousdiner.staffreportperiod srp - LEFT JOIN lousdiner.staff st ON srp.id_staff = st.id - LEFT JOIN lousdiner.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN lousdiner.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = '0e758e4f-a9b4-3c18-9bbf-52baa78c8dd8' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='lousdiner'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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.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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select sessiondata from public.sessions where id='6cfa9047-f585-a84b-62b0-0e0a53c9fd08' -EXEC: update public.sessions set sessiondata='{"schemata":"alicehartmann"}' where id='6cfa9047-f585-a84b-62b0-0e0a53c9fd08' -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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.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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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 alicehartmann.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 alicehartmann.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = '2cdf9b30-bbdf-0a25-a736-1c569b116069' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id from alicehartmann.staff where isdeleted is null; -QUERYARRAY: select id from alicehartmann.reportperiod order by startdate,enddate; -QUERYARRAY: select id,startdate,enddate from alicehartmann.reportperiod where -startdate >= date((select min(startdate) from alicehartmann.staffcontract where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27')) -or date((select min(startdate) from alicehartmann.staffcontract where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27')) between startdate and enddate order by startdate,enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='2cdf9b30-bbdf-0a25-a736-1c569b116069'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('2cdf9b30-bbdf-0a25-a736-1c569b116069','9b03bc70-eb30-c3a6-da52-6b80d4e1dd27') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='86c57b67-0f53-6906-da9f-03e90e03afc6'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('86c57b67-0f53-6906-da9f-03e90e03afc6','9b03bc70-eb30-c3a6-da52-6b80d4e1dd27') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('90632f2f-6134-65d8-bfd0-ab2ece5f7f7f','9b03bc70-eb30-c3a6-da52-6b80d4e1dd27') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('a0f71278-f95c-bffd-8dd7-d502f0cc88aa','9b03bc70-eb30-c3a6-da52-6b80d4e1dd27') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='a565664b-07b7-a90d-be8b-14a585d7766d'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('a565664b-07b7-a90d-be8b-14a585d7766d','9b03bc70-eb30-c3a6-da52-6b80d4e1dd27') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('9a1ca2f0-c1d7-8652-69d9-9dc25057efe8','9b03bc70-eb30-c3a6-da52-6b80d4e1dd27') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='5d40fe41-c607-b65b-0866-30298ba9833e'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('5d40fe41-c607-b65b-0866-30298ba9833e','9b03bc70-eb30-c3a6-da52-6b80d4e1dd27') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select reportperiodunit,reportperiodlength from public.companies where schemata='alicehartmann' -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' - ) scx where startdate < enddate and id='2cdf9b30-bbdf-0a25-a736-1c569b116069' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-01-01'),date('2021-04-30'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 86 as maxdays,86 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from alicehartmann.staffreportperioddays - where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date('2021-01-01') and date('2021-04-30') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-04-30') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-04-30')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from alicehartmann.staffcontract where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update alicehartmann.staffreportperiod set maxdays=86,contracthours='688:00:00' where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod='2cdf9b30-bbdf-0a25-a736-1c569b116069'; -QUERY: select * from alicehartmann.reportperiod where id='2cdf9b30-bbdf-0a25-a736-1c569b116069'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by rp.startdate,rp.enddate) - sper ) prp where id='2cdf9b30-bbdf-0a25-a736-1c569b116069'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-01-01') and date('2021-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and sr.daydate between date('2021-01-01') and date(date_trunc('week',date('2021-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days') - --where id_staff= '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date('2021-01-01') and date('2021-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=4,last44date=date('2021-03-22'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '2cdf9b30-bbdf-0a25-a736-1c569b116069') - where pd.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and pd.daydate between date('2021-01-01') and date('2021-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' - ) scx where startdate < enddate and id='86c57b67-0f53-6906-da9f-03e90e03afc6' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-05-01'),date('2021-08-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 87 as maxdays,87 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from alicehartmann.staffreportperioddays - where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date('2021-05-01') and date('2021-08-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-08-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-08-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from alicehartmann.staffcontract where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update alicehartmann.staffreportperiod set maxdays=87,contracthours='696:00:00' where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod='86c57b67-0f53-6906-da9f-03e90e03afc6'; -QUERY: select * from alicehartmann.reportperiod where id='86c57b67-0f53-6906-da9f-03e90e03afc6'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by rp.startdate,rp.enddate) - sper ) prp where id='86c57b67-0f53-6906-da9f-03e90e03afc6'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='2cdf9b30-bbdf-0a25-a736-1c569b116069' and id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-05-01') and date('2021-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,4+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and sr.daydate between date('2021-03-22') and date(date_trunc('week',date('2021-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days') - --where id_staff= '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date('2021-05-01') and date('2021-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=1,status44hcount=0,last44date=date('2021-08-30'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '86c57b67-0f53-6906-da9f-03e90e03afc6') - where pd.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and pd.daydate between date('2021-05-01') and date('2021-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' - ) scx where startdate < enddate and id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-09-01'),date('2021-12-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 88 as maxdays,88 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from alicehartmann.staffreportperioddays - where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date('2021-09-01') and date('2021-12-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-12-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-12-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from alicehartmann.staffcontract where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update alicehartmann.staffreportperiod set maxdays=88,contracthours='704:00:00' where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select * from alicehartmann.reportperiod where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by rp.startdate,rp.enddate) - sper ) prp where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='86c57b67-0f53-6906-da9f-03e90e03afc6' and id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-09-01') and date('2021-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,0+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and sr.daydate between date('2021-08-30') and date(date_trunc('week',date('2021-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days') - --where id_staff= '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date('2021-09-01') and date('2021-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=6,last44date=date('2021-12-27'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '90632f2f-6134-65d8-bfd0-ab2ece5f7f7f') - where pd.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and pd.daydate between date('2021-09-01') and date('2021-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' - ) scx where startdate < enddate and id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2022-01-01'),date('2022-04-30'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 85 as maxdays,85 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from alicehartmann.staffreportperioddays - where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date('2022-01-01') and date('2022-04-30') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2022-04-30') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2022-04-30')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from alicehartmann.staffcontract where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update alicehartmann.staffreportperiod set maxdays=85,contracthours='680:00:00' where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -QUERY: select * from alicehartmann.reportperiod where id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by rp.startdate,rp.enddate) - sper ) prp where id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f' and id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2022-01-01') and date('2022-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,6+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and sr.daydate between date('2021-12-27') and date(date_trunc('week',date('2022-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-04-30')) + interval '6 days') - --where id_staff= '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date('2022-01-01') and date('2022-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=2,status44hcount=3,last44date=date('2022-04-25'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a0f71278-f95c-bffd-8dd7-d502f0cc88aa') - where pd.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and pd.daydate between date('2022-01-01') and date('2022-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' - ) scx where startdate < enddate and id='a565664b-07b7-a90d-be8b-14a585d7766d' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2022-05-01'),date('2022-08-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 88 as maxdays,88 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from alicehartmann.staffreportperioddays - where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date('2022-05-01') and date('2022-08-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2022-08-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2022-08-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from alicehartmann.staffcontract where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update alicehartmann.staffreportperiod set maxdays=88,contracthours='704:00:00' where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod='a565664b-07b7-a90d-be8b-14a585d7766d'; -QUERY: select * from alicehartmann.reportperiod where id='a565664b-07b7-a90d-be8b-14a585d7766d'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by rp.startdate,rp.enddate) - sper ) prp where id='a565664b-07b7-a90d-be8b-14a585d7766d'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2022-05-01'))) and date(date_trunc('week',date('2022-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2022-05-01'))) and date(date_trunc('week',date('2022-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='a0f71278-f95c-bffd-8dd7-d502f0cc88aa' and id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2022-05-01') and date('2022-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,3+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and sr.daydate between date('2022-04-25') and date(date_trunc('week',date('2022-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2022-05-01'))) and date(date_trunc('week',date('2022-08-31')) + interval '6 days') - --where id_staff= '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date('2022-05-01') and date('2022-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=7,last44date=date('2022-08-29'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a565664b-07b7-a90d-be8b-14a585d7766d') - where pd.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and pd.daydate between date('2022-05-01') and date('2022-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' - ) scx where startdate < enddate and id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2022-09-01'),date('2022-12-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 87 as maxdays,87 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from alicehartmann.staffreportperioddays - where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date('2022-09-01') and date('2022-12-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2022-12-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2022-12-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from alicehartmann.staffcontract where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update alicehartmann.staffreportperiod set maxdays=87,contracthours='696:00:00' where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -QUERY: select * from alicehartmann.reportperiod where id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by rp.startdate,rp.enddate) - sper ) prp where id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2022-09-01'))) and date(date_trunc('week',date('2022-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2022-09-01'))) and date(date_trunc('week',date('2022-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='a565664b-07b7-a90d-be8b-14a585d7766d' and id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2022-09-01') and date('2022-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,7+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and sr.daydate between date('2022-08-29') and date(date_trunc('week',date('2022-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2022-09-01'))) and date(date_trunc('week',date('2022-12-31')) + interval '6 days') - --where id_staff= '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date('2022-09-01') and date('2022-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=1,status44hcount=1,last44date=date('2022-12-26'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '9a1ca2f0-c1d7-8652-69d9-9dc25057efe8') - where pd.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and pd.daydate between date('2022-09-01') and date('2022-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' - ) scx where startdate < enddate and id='5d40fe41-c607-b65b-0866-30298ba9833e' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2023-01-01'),date('2023-04-30'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 85 as maxdays,85 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from alicehartmann.staffreportperioddays - where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date('2023-01-01') and date('2023-04-30') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2023-04-30') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2023-04-30')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from alicehartmann.staffcontract where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update alicehartmann.staffreportperiod set maxdays=85,contracthours='680:00:00' where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod='5d40fe41-c607-b65b-0866-30298ba9833e'; -QUERY: select * from alicehartmann.reportperiod where id='5d40fe41-c607-b65b-0866-30298ba9833e'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by rp.startdate,rp.enddate) - sper ) prp where id='5d40fe41-c607-b65b-0866-30298ba9833e'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2023-01-01'))) and date(date_trunc('week',date('2023-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2023-01-01'))) and date(date_trunc('week',date('2023-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8' and id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2023-01-01') and date('2023-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2023-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,1+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and sr.daydate between date('2022-12-26') and date(date_trunc('week',date('2023-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2023-01-01'))) and date(date_trunc('week',date('2023-04-30')) + interval '6 days') - --where id_staff= '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date('2023-01-01') and date('2023-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2023-01-02'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '5d40fe41-c607-b65b-0866-30298ba9833e') - where pd.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and pd.daydate between date('2023-01-01') and date('2023-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -EXEC: insert into alicehartmann.staffvacancyyear (id_staff,vacyear) - select id_staff,to_char(daydate,'YYYY')::int4 as vyear from alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' group by id_staff,vyear order by id_staff,vyear - on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='2cdf9b30-bbdf-0a25-a736-1c569b116069'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='2cdf9b30-bbdf-0a25-a736-1c569b116069'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by rp.startdate,rp.enddate) - sper ) prp where id='2cdf9b30-bbdf-0a25-a736-1c569b116069'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-01-01') and date('2021-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and sr.daydate between date('2021-01-01') and date(date_trunc('week',date('2021-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days') - --where id_staff= '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date('2021-01-01') and date('2021-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=4,last44date=date('2021-03-22'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '2cdf9b30-bbdf-0a25-a736-1c569b116069') - where pd.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and pd.daydate between date('2021-01-01') and date('2021-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='86c57b67-0f53-6906-da9f-03e90e03afc6'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='86c57b67-0f53-6906-da9f-03e90e03afc6'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by rp.startdate,rp.enddate) - sper ) prp where id='86c57b67-0f53-6906-da9f-03e90e03afc6'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='2cdf9b30-bbdf-0a25-a736-1c569b116069' and id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-05-01') and date('2021-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,4+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and sr.daydate between date('2021-03-22') and date(date_trunc('week',date('2021-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days') - --where id_staff= '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date('2021-05-01') and date('2021-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=1,status44hcount=0,last44date=date('2021-08-30'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '86c57b67-0f53-6906-da9f-03e90e03afc6') - where pd.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and pd.daydate between date('2021-05-01') and date('2021-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by rp.startdate,rp.enddate) - sper ) prp where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='86c57b67-0f53-6906-da9f-03e90e03afc6' and id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-09-01') and date('2021-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,0+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and sr.daydate between date('2021-08-30') and date(date_trunc('week',date('2021-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days') - --where id_staff= '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date('2021-09-01') and date('2021-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=6,last44date=date('2021-12-27'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '90632f2f-6134-65d8-bfd0-ab2ece5f7f7f') - where pd.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and pd.daydate between date('2021-09-01') and date('2021-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by rp.startdate,rp.enddate) - sper ) prp where id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f' and id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2022-01-01') and date('2022-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,6+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and sr.daydate between date('2021-12-27') and date(date_trunc('week',date('2022-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-04-30')) + interval '6 days') - --where id_staff= '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date('2022-01-01') and date('2022-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=2,status44hcount=3,last44date=date('2022-04-25'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a0f71278-f95c-bffd-8dd7-d502f0cc88aa') - where pd.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and pd.daydate between date('2022-01-01') and date('2022-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='a565664b-07b7-a90d-be8b-14a585d7766d'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='a565664b-07b7-a90d-be8b-14a585d7766d'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by rp.startdate,rp.enddate) - sper ) prp where id='a565664b-07b7-a90d-be8b-14a585d7766d'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2022-05-01'))) and date(date_trunc('week',date('2022-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2022-05-01'))) and date(date_trunc('week',date('2022-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='a0f71278-f95c-bffd-8dd7-d502f0cc88aa' and id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2022-05-01') and date('2022-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,3+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and sr.daydate between date('2022-04-25') and date(date_trunc('week',date('2022-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2022-05-01'))) and date(date_trunc('week',date('2022-08-31')) + interval '6 days') - --where id_staff= '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date('2022-05-01') and date('2022-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=7,last44date=date('2022-08-29'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a565664b-07b7-a90d-be8b-14a585d7766d') - where pd.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and pd.daydate between date('2022-05-01') and date('2022-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by rp.startdate,rp.enddate) - sper ) prp where id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2022-09-01'))) and date(date_trunc('week',date('2022-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2022-09-01'))) and date(date_trunc('week',date('2022-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='a565664b-07b7-a90d-be8b-14a585d7766d' and id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2022-09-01') and date('2022-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,7+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and sr.daydate between date('2022-08-29') and date(date_trunc('week',date('2022-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2022-09-01'))) and date(date_trunc('week',date('2022-12-31')) + interval '6 days') - --where id_staff= '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date('2022-09-01') and date('2022-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=1,status44hcount=1,last44date=date('2022-12-26'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '9a1ca2f0-c1d7-8652-69d9-9dc25057efe8') - where pd.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and pd.daydate between date('2022-09-01') and date('2022-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='5d40fe41-c607-b65b-0866-30298ba9833e'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='5d40fe41-c607-b65b-0866-30298ba9833e'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by rp.startdate,rp.enddate) - sper ) prp where id='5d40fe41-c607-b65b-0866-30298ba9833e'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2023-01-01'))) and date(date_trunc('week',date('2023-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2023-01-01'))) and date(date_trunc('week',date('2023-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8' and id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2023-01-01') and date('2023-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2023-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,1+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and sr.daydate between date('2022-12-26') and date(date_trunc('week',date('2023-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date(date_trunc('week',date('2023-01-01'))) and date(date_trunc('week',date('2023-04-30')) + interval '6 days') - --where id_staff= '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and daydate between date('2023-01-01') and date('2023-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2023-01-02'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '5d40fe41-c607-b65b-0866-30298ba9833e') - where pd.id_staff='9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' and pd.daydate between date('2023-01-01') and date('2023-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '9b03bc70-eb30-c3a6-da52-6b80d4e1dd27' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id from alicehartmann.reportperiod order by startdate,enddate; -QUERYARRAY: select id,startdate,enddate from alicehartmann.reportperiod where -startdate >= date((select min(startdate) from alicehartmann.staffcontract where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9')) -or date((select min(startdate) from alicehartmann.staffcontract where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9')) between startdate and enddate order by startdate,enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='2cdf9b30-bbdf-0a25-a736-1c569b116069'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'07873ca1-0a31-023c-0bf3-4b6b0784cce9' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'07873ca1-0a31-023c-0bf3-4b6b0784cce9' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('2cdf9b30-bbdf-0a25-a736-1c569b116069','07873ca1-0a31-023c-0bf3-4b6b0784cce9') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='86c57b67-0f53-6906-da9f-03e90e03afc6'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'07873ca1-0a31-023c-0bf3-4b6b0784cce9' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'07873ca1-0a31-023c-0bf3-4b6b0784cce9' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('86c57b67-0f53-6906-da9f-03e90e03afc6','07873ca1-0a31-023c-0bf3-4b6b0784cce9') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'07873ca1-0a31-023c-0bf3-4b6b0784cce9' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'07873ca1-0a31-023c-0bf3-4b6b0784cce9' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('90632f2f-6134-65d8-bfd0-ab2ece5f7f7f','07873ca1-0a31-023c-0bf3-4b6b0784cce9') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'07873ca1-0a31-023c-0bf3-4b6b0784cce9' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'07873ca1-0a31-023c-0bf3-4b6b0784cce9' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('a0f71278-f95c-bffd-8dd7-d502f0cc88aa','07873ca1-0a31-023c-0bf3-4b6b0784cce9') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='a565664b-07b7-a90d-be8b-14a585d7766d'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'07873ca1-0a31-023c-0bf3-4b6b0784cce9' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'07873ca1-0a31-023c-0bf3-4b6b0784cce9' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('a565664b-07b7-a90d-be8b-14a585d7766d','07873ca1-0a31-023c-0bf3-4b6b0784cce9') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'07873ca1-0a31-023c-0bf3-4b6b0784cce9' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'07873ca1-0a31-023c-0bf3-4b6b0784cce9' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('9a1ca2f0-c1d7-8652-69d9-9dc25057efe8','07873ca1-0a31-023c-0bf3-4b6b0784cce9') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='5d40fe41-c607-b65b-0866-30298ba9833e'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'07873ca1-0a31-023c-0bf3-4b6b0784cce9' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'07873ca1-0a31-023c-0bf3-4b6b0784cce9' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('5d40fe41-c607-b65b-0866-30298ba9833e','07873ca1-0a31-023c-0bf3-4b6b0784cce9') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select reportperiodunit,reportperiodlength from public.companies where schemata='alicehartmann' -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' - ) scx where startdate < enddate and id='2cdf9b30-bbdf-0a25-a736-1c569b116069' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-01-01'),date('2021-04-30'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 86 as maxdays,86 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from alicehartmann.staffreportperioddays - where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date('2021-01-01') and date('2021-04-30') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-04-30') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-04-30')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from alicehartmann.staffcontract where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update alicehartmann.staffreportperiod set maxdays=86,contracthours='688:00:00' where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod='2cdf9b30-bbdf-0a25-a736-1c569b116069'; -QUERY: select * from alicehartmann.reportperiod where id='2cdf9b30-bbdf-0a25-a736-1c569b116069'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by rp.startdate,rp.enddate) - sper ) prp where id='2cdf9b30-bbdf-0a25-a736-1c569b116069'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-01-01') and date('2021-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and sr.daydate between date('2021-01-01') and date(date_trunc('week',date('2021-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days') - --where id_staff= '07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date('2021-01-01') and date('2021-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2021-04-26'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '2cdf9b30-bbdf-0a25-a736-1c569b116069') - where pd.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and pd.daydate between date('2021-01-01') and date('2021-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '07873ca1-0a31-023c-0bf3-4b6b0784cce9' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' - ) scx where startdate < enddate and id='86c57b67-0f53-6906-da9f-03e90e03afc6' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-05-01'),date('2021-08-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 87 as maxdays,87 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from alicehartmann.staffreportperioddays - where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date('2021-05-01') and date('2021-08-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-08-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-08-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from alicehartmann.staffcontract where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update alicehartmann.staffreportperiod set maxdays=87,contracthours='696:00:00' where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod='86c57b67-0f53-6906-da9f-03e90e03afc6'; -QUERY: select * from alicehartmann.reportperiod where id='86c57b67-0f53-6906-da9f-03e90e03afc6'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by rp.startdate,rp.enddate) - sper ) prp where id='86c57b67-0f53-6906-da9f-03e90e03afc6'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='2cdf9b30-bbdf-0a25-a736-1c569b116069' and id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-05-01') and date('2021-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,2+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and sr.daydate between date('2021-04-26') and date(date_trunc('week',date('2021-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days') - --where id_staff= '07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date('2021-05-01') and date('2021-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2021-05-03'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '86c57b67-0f53-6906-da9f-03e90e03afc6') - where pd.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and pd.daydate between date('2021-05-01') and date('2021-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '07873ca1-0a31-023c-0bf3-4b6b0784cce9' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' - ) scx where startdate < enddate and id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-09-01'),date('2021-12-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 88 as maxdays,88 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from alicehartmann.staffreportperioddays - where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date('2021-09-01') and date('2021-12-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-12-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-12-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from alicehartmann.staffcontract where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update alicehartmann.staffreportperiod set maxdays=88,contracthours='704:00:00' where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select * from alicehartmann.reportperiod where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by rp.startdate,rp.enddate) - sper ) prp where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='86c57b67-0f53-6906-da9f-03e90e03afc6' and id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-09-01') and date('2021-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,3+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and sr.daydate between date('2021-05-03') and date(date_trunc('week',date('2021-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days') - --where id_staff= '07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date('2021-09-01') and date('2021-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=7,last44date=date('2021-12-27'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '90632f2f-6134-65d8-bfd0-ab2ece5f7f7f') - where pd.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and pd.daydate between date('2021-09-01') and date('2021-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '07873ca1-0a31-023c-0bf3-4b6b0784cce9' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' - ) scx where startdate < enddate and id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2022-01-01'),date('2022-04-30'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 85 as maxdays,85 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from alicehartmann.staffreportperioddays - where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date('2022-01-01') and date('2022-04-30') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2022-04-30') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2022-04-30')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from alicehartmann.staffcontract where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update alicehartmann.staffreportperiod set maxdays=85,contracthours='680:00:00' where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -QUERY: select * from alicehartmann.reportperiod where id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by rp.startdate,rp.enddate) - sper ) prp where id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f' and id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2022-01-01') and date('2022-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,7+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and sr.daydate between date('2021-12-27') and date(date_trunc('week',date('2022-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-04-30')) + interval '6 days') - --where id_staff= '07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date('2022-01-01') and date('2022-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=1,status44hcount=7,last44date=date('2022-04-25'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a0f71278-f95c-bffd-8dd7-d502f0cc88aa') - where pd.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and pd.daydate between date('2022-01-01') and date('2022-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '07873ca1-0a31-023c-0bf3-4b6b0784cce9' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' - ) scx where startdate < enddate and id='a565664b-07b7-a90d-be8b-14a585d7766d' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2022-05-01'),date('2022-08-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 88 as maxdays,88 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from alicehartmann.staffreportperioddays - where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date('2022-05-01') and date('2022-08-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2022-08-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2022-08-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from alicehartmann.staffcontract where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update alicehartmann.staffreportperiod set maxdays=88,contracthours='704:00:00' where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod='a565664b-07b7-a90d-be8b-14a585d7766d'; -QUERY: select * from alicehartmann.reportperiod where id='a565664b-07b7-a90d-be8b-14a585d7766d'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by rp.startdate,rp.enddate) - sper ) prp where id='a565664b-07b7-a90d-be8b-14a585d7766d'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2022-05-01'))) and date(date_trunc('week',date('2022-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2022-05-01'))) and date(date_trunc('week',date('2022-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='a0f71278-f95c-bffd-8dd7-d502f0cc88aa' and id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2022-05-01') and date('2022-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,7+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and sr.daydate between date('2022-04-25') and date(date_trunc('week',date('2022-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2022-05-01'))) and date(date_trunc('week',date('2022-08-31')) + interval '6 days') - --where id_staff= '07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date('2022-05-01') and date('2022-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=1,status44hcount=5,last44date=date('2022-08-29'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a565664b-07b7-a90d-be8b-14a585d7766d') - where pd.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and pd.daydate between date('2022-05-01') and date('2022-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '07873ca1-0a31-023c-0bf3-4b6b0784cce9' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' - ) scx where startdate < enddate and id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2022-09-01'),date('2022-12-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 87 as maxdays,87 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from alicehartmann.staffreportperioddays - where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date('2022-09-01') and date('2022-12-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2022-12-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2022-12-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from alicehartmann.staffcontract where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update alicehartmann.staffreportperiod set maxdays=87,contracthours='696:00:00' where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -QUERY: select * from alicehartmann.reportperiod where id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by rp.startdate,rp.enddate) - sper ) prp where id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2022-09-01'))) and date(date_trunc('week',date('2022-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2022-09-01'))) and date(date_trunc('week',date('2022-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='a565664b-07b7-a90d-be8b-14a585d7766d' and id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2022-09-01') and date('2022-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,5+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and sr.daydate between date('2022-08-29') and date(date_trunc('week',date('2022-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2022-09-01'))) and date(date_trunc('week',date('2022-12-31')) + interval '6 days') - --where id_staff= '07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date('2022-09-01') and date('2022-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=7,last44date=date('2022-11-07'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '9a1ca2f0-c1d7-8652-69d9-9dc25057efe8') - where pd.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and pd.daydate between date('2022-09-01') and date('2022-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '07873ca1-0a31-023c-0bf3-4b6b0784cce9' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' - ) scx where startdate < enddate and id='5d40fe41-c607-b65b-0866-30298ba9833e' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2023-01-01'),date('2023-04-30'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 85 as maxdays,85 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from alicehartmann.staffreportperioddays - where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date('2023-01-01') and date('2023-04-30') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2023-04-30') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2023-04-30')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from alicehartmann.staffcontract where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update alicehartmann.staffreportperiod set maxdays=85,contracthours='680:00:00' where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod='5d40fe41-c607-b65b-0866-30298ba9833e'; -QUERY: select * from alicehartmann.reportperiod where id='5d40fe41-c607-b65b-0866-30298ba9833e'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by rp.startdate,rp.enddate) - sper ) prp where id='5d40fe41-c607-b65b-0866-30298ba9833e'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2023-01-01'))) and date(date_trunc('week',date('2023-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2023-01-01'))) and date(date_trunc('week',date('2023-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8' and id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2023-01-01') and date('2023-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2023-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,7+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and sr.daydate between date('2022-11-07') and date(date_trunc('week',date('2023-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2023-01-01'))) and date(date_trunc('week',date('2023-04-30')) + interval '6 days') - --where id_staff= '07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date('2023-01-01') and date('2023-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=1,status44hcount=0,last44date=date('2023-01-02'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '5d40fe41-c607-b65b-0866-30298ba9833e') - where pd.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and pd.daydate between date('2023-01-01') and date('2023-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '07873ca1-0a31-023c-0bf3-4b6b0784cce9' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -EXEC: insert into alicehartmann.staffvacancyyear (id_staff,vacyear) - select id_staff,to_char(daydate,'YYYY')::int4 as vyear from alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' group by id_staff,vyear order by id_staff,vyear - on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='2cdf9b30-bbdf-0a25-a736-1c569b116069'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'07873ca1-0a31-023c-0bf3-4b6b0784cce9' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'07873ca1-0a31-023c-0bf3-4b6b0784cce9' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='2cdf9b30-bbdf-0a25-a736-1c569b116069'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by rp.startdate,rp.enddate) - sper ) prp where id='2cdf9b30-bbdf-0a25-a736-1c569b116069'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-01-01') and date('2021-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and sr.daydate between date('2021-01-01') and date(date_trunc('week',date('2021-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days') - --where id_staff= '07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date('2021-01-01') and date('2021-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2021-04-26'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '2cdf9b30-bbdf-0a25-a736-1c569b116069') - where pd.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and pd.daydate between date('2021-01-01') and date('2021-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '07873ca1-0a31-023c-0bf3-4b6b0784cce9' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='86c57b67-0f53-6906-da9f-03e90e03afc6'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'07873ca1-0a31-023c-0bf3-4b6b0784cce9' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'07873ca1-0a31-023c-0bf3-4b6b0784cce9' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='86c57b67-0f53-6906-da9f-03e90e03afc6'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by rp.startdate,rp.enddate) - sper ) prp where id='86c57b67-0f53-6906-da9f-03e90e03afc6'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='2cdf9b30-bbdf-0a25-a736-1c569b116069' and id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-05-01') and date('2021-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,2+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and sr.daydate between date('2021-04-26') and date(date_trunc('week',date('2021-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days') - --where id_staff= '07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date('2021-05-01') and date('2021-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2021-05-03'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '86c57b67-0f53-6906-da9f-03e90e03afc6') - where pd.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and pd.daydate between date('2021-05-01') and date('2021-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '07873ca1-0a31-023c-0bf3-4b6b0784cce9' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'07873ca1-0a31-023c-0bf3-4b6b0784cce9' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'07873ca1-0a31-023c-0bf3-4b6b0784cce9' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by rp.startdate,rp.enddate) - sper ) prp where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='86c57b67-0f53-6906-da9f-03e90e03afc6' and id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-09-01') and date('2021-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,3+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and sr.daydate between date('2021-05-03') and date(date_trunc('week',date('2021-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days') - --where id_staff= '07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date('2021-09-01') and date('2021-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=7,last44date=date('2021-12-27'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '90632f2f-6134-65d8-bfd0-ab2ece5f7f7f') - where pd.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and pd.daydate between date('2021-09-01') and date('2021-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '07873ca1-0a31-023c-0bf3-4b6b0784cce9' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'07873ca1-0a31-023c-0bf3-4b6b0784cce9' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'07873ca1-0a31-023c-0bf3-4b6b0784cce9' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by rp.startdate,rp.enddate) - sper ) prp where id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f' and id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2022-01-01') and date('2022-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,7+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and sr.daydate between date('2021-12-27') and date(date_trunc('week',date('2022-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-04-30')) + interval '6 days') - --where id_staff= '07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date('2022-01-01') and date('2022-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=1,status44hcount=7,last44date=date('2022-04-25'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a0f71278-f95c-bffd-8dd7-d502f0cc88aa') - where pd.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and pd.daydate between date('2022-01-01') and date('2022-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '07873ca1-0a31-023c-0bf3-4b6b0784cce9' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='a565664b-07b7-a90d-be8b-14a585d7766d'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'07873ca1-0a31-023c-0bf3-4b6b0784cce9' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'07873ca1-0a31-023c-0bf3-4b6b0784cce9' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='a565664b-07b7-a90d-be8b-14a585d7766d'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by rp.startdate,rp.enddate) - sper ) prp where id='a565664b-07b7-a90d-be8b-14a585d7766d'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2022-05-01'))) and date(date_trunc('week',date('2022-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2022-05-01'))) and date(date_trunc('week',date('2022-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='a0f71278-f95c-bffd-8dd7-d502f0cc88aa' and id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2022-05-01') and date('2022-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,7+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and sr.daydate between date('2022-04-25') and date(date_trunc('week',date('2022-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2022-05-01'))) and date(date_trunc('week',date('2022-08-31')) + interval '6 days') - --where id_staff= '07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date('2022-05-01') and date('2022-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=1,status44hcount=5,last44date=date('2022-08-29'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a565664b-07b7-a90d-be8b-14a585d7766d') - where pd.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and pd.daydate between date('2022-05-01') and date('2022-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '07873ca1-0a31-023c-0bf3-4b6b0784cce9' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'07873ca1-0a31-023c-0bf3-4b6b0784cce9' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'07873ca1-0a31-023c-0bf3-4b6b0784cce9' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by rp.startdate,rp.enddate) - sper ) prp where id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2022-09-01'))) and date(date_trunc('week',date('2022-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2022-09-01'))) and date(date_trunc('week',date('2022-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='a565664b-07b7-a90d-be8b-14a585d7766d' and id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2022-09-01') and date('2022-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,5+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and sr.daydate between date('2022-08-29') and date(date_trunc('week',date('2022-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2022-09-01'))) and date(date_trunc('week',date('2022-12-31')) + interval '6 days') - --where id_staff= '07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date('2022-09-01') and date('2022-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=7,last44date=date('2022-11-07'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '9a1ca2f0-c1d7-8652-69d9-9dc25057efe8') - where pd.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and pd.daydate between date('2022-09-01') and date('2022-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '07873ca1-0a31-023c-0bf3-4b6b0784cce9' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='5d40fe41-c607-b65b-0866-30298ba9833e'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'07873ca1-0a31-023c-0bf3-4b6b0784cce9' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'07873ca1-0a31-023c-0bf3-4b6b0784cce9' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='5d40fe41-c607-b65b-0866-30298ba9833e'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by rp.startdate,rp.enddate) - sper ) prp where id='5d40fe41-c607-b65b-0866-30298ba9833e'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2023-01-01'))) and date(date_trunc('week',date('2023-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2023-01-01'))) and date(date_trunc('week',date('2023-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8' and id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2023-01-01') and date('2023-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2023-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,7+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and sr.daydate between date('2022-11-07') and date(date_trunc('week',date('2023-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date(date_trunc('week',date('2023-01-01'))) and date(date_trunc('week',date('2023-04-30')) + interval '6 days') - --where id_staff= '07873ca1-0a31-023c-0bf3-4b6b0784cce9' and daydate between date('2023-01-01') and date('2023-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=1,status44hcount=0,last44date=date('2023-01-02'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '5d40fe41-c607-b65b-0866-30298ba9833e') - where pd.id_staff='07873ca1-0a31-023c-0bf3-4b6b0784cce9' and pd.daydate between date('2023-01-01') and date('2023-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '07873ca1-0a31-023c-0bf3-4b6b0784cce9' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id from alicehartmann.reportperiod order by startdate,enddate; -QUERYARRAY: select id,startdate,enddate from alicehartmann.reportperiod where -startdate >= date((select min(startdate) from alicehartmann.staffcontract where id_staff='4e9801a0-002a-a870-8555-f9123030af59')) -or date((select min(startdate) from alicehartmann.staffcontract where id_staff='4e9801a0-002a-a870-8555-f9123030af59')) between startdate and enddate order by startdate,enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'4e9801a0-002a-a870-8555-f9123030af59' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='4e9801a0-002a-a870-8555-f9123030af59' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'4e9801a0-002a-a870-8555-f9123030af59' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='4e9801a0-002a-a870-8555-f9123030af59' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='4e9801a0-002a-a870-8555-f9123030af59' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('90632f2f-6134-65d8-bfd0-ab2ece5f7f7f','4e9801a0-002a-a870-8555-f9123030af59') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'4e9801a0-002a-a870-8555-f9123030af59' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='4e9801a0-002a-a870-8555-f9123030af59' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'4e9801a0-002a-a870-8555-f9123030af59' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='4e9801a0-002a-a870-8555-f9123030af59' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='4e9801a0-002a-a870-8555-f9123030af59' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('a0f71278-f95c-bffd-8dd7-d502f0cc88aa','4e9801a0-002a-a870-8555-f9123030af59') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='a565664b-07b7-a90d-be8b-14a585d7766d'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'4e9801a0-002a-a870-8555-f9123030af59' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='4e9801a0-002a-a870-8555-f9123030af59' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'4e9801a0-002a-a870-8555-f9123030af59' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='4e9801a0-002a-a870-8555-f9123030af59' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='4e9801a0-002a-a870-8555-f9123030af59' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('a565664b-07b7-a90d-be8b-14a585d7766d','4e9801a0-002a-a870-8555-f9123030af59') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'4e9801a0-002a-a870-8555-f9123030af59' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='4e9801a0-002a-a870-8555-f9123030af59' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'4e9801a0-002a-a870-8555-f9123030af59' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='4e9801a0-002a-a870-8555-f9123030af59' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='4e9801a0-002a-a870-8555-f9123030af59' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('9a1ca2f0-c1d7-8652-69d9-9dc25057efe8','4e9801a0-002a-a870-8555-f9123030af59') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='5d40fe41-c607-b65b-0866-30298ba9833e'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'4e9801a0-002a-a870-8555-f9123030af59' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='4e9801a0-002a-a870-8555-f9123030af59' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'4e9801a0-002a-a870-8555-f9123030af59' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='4e9801a0-002a-a870-8555-f9123030af59' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='4e9801a0-002a-a870-8555-f9123030af59' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('5d40fe41-c607-b65b-0866-30298ba9833e','4e9801a0-002a-a870-8555-f9123030af59') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select reportperiodunit,reportperiodlength from public.companies where schemata='alicehartmann' -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='4e9801a0-002a-a870-8555-f9123030af59' - ) scx where startdate < enddate and id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-10-11'),date('2021-11-09'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 22 as maxdays,22 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from alicehartmann.staffreportperioddays - where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and daydate between date('2021-09-01') and date('2021-12-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-12-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-12-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from alicehartmann.staffcontract where id_staff='4e9801a0-002a-a870-8555-f9123030af59' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update alicehartmann.staffreportperiod set maxdays=22,contracthours='176:00:00' where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and id_reportperiod='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select * from alicehartmann.reportperiod where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='4e9801a0-002a-a870-8555-f9123030af59' order by rp.startdate,rp.enddate) - sper ) prp where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-09-01') and date('2021-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='4e9801a0-002a-a870-8555-f9123030af59' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='4e9801a0-002a-a870-8555-f9123030af59' and sr.daydate between date('2021-09-01') and date(date_trunc('week',date('2021-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '4e9801a0-002a-a870-8555-f9123030af59' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days') - --where id_staff= '4e9801a0-002a-a870-8555-f9123030af59' and daydate between date('2021-09-01') and date('2021-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=5,last44date=date('2021-11-15'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '90632f2f-6134-65d8-bfd0-ab2ece5f7f7f') - where pd.id_staff='4e9801a0-002a-a870-8555-f9123030af59' and pd.daydate between date('2021-09-01') and date('2021-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '4e9801a0-002a-a870-8555-f9123030af59' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='4e9801a0-002a-a870-8555-f9123030af59' - ) scx where startdate < enddate and id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa' order by startdate,enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='4e9801a0-002a-a870-8555-f9123030af59' - ) scx where startdate < enddate and id='a565664b-07b7-a90d-be8b-14a585d7766d' order by startdate,enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='4e9801a0-002a-a870-8555-f9123030af59' - ) scx where startdate < enddate and id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8' order by startdate,enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='4e9801a0-002a-a870-8555-f9123030af59' - ) scx where startdate < enddate and id='5d40fe41-c607-b65b-0866-30298ba9833e' order by startdate,enddate; -EXEC: insert into alicehartmann.staffvacancyyear (id_staff,vacyear) - select id_staff,to_char(daydate,'YYYY')::int4 as vyear from alicehartmann.staffreportperioddays where id_staff='4e9801a0-002a-a870-8555-f9123030af59' group by id_staff,vyear order by id_staff,vyear - on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='2cdf9b30-bbdf-0a25-a736-1c569b116069'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'4e9801a0-002a-a870-8555-f9123030af59' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='4e9801a0-002a-a870-8555-f9123030af59' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'4e9801a0-002a-a870-8555-f9123030af59' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='4e9801a0-002a-a870-8555-f9123030af59' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='4e9801a0-002a-a870-8555-f9123030af59' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='2cdf9b30-bbdf-0a25-a736-1c569b116069'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='4e9801a0-002a-a870-8555-f9123030af59' order by rp.startdate,rp.enddate) - sper ) prp where id='2cdf9b30-bbdf-0a25-a736-1c569b116069'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-01-01') and date('2021-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='4e9801a0-002a-a870-8555-f9123030af59' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='4e9801a0-002a-a870-8555-f9123030af59' and sr.daydate between date('2021-01-01') and date(date_trunc('week',date('2021-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '4e9801a0-002a-a870-8555-f9123030af59' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days') - --where id_staff= '4e9801a0-002a-a870-8555-f9123030af59' and daydate between date('2021-01-01') and date('2021-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '2cdf9b30-bbdf-0a25-a736-1c569b116069') - where pd.id_staff='4e9801a0-002a-a870-8555-f9123030af59' and pd.daydate between date('2021-01-01') and date('2021-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '4e9801a0-002a-a870-8555-f9123030af59' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='86c57b67-0f53-6906-da9f-03e90e03afc6'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'4e9801a0-002a-a870-8555-f9123030af59' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='4e9801a0-002a-a870-8555-f9123030af59' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'4e9801a0-002a-a870-8555-f9123030af59' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='4e9801a0-002a-a870-8555-f9123030af59' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='4e9801a0-002a-a870-8555-f9123030af59' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='86c57b67-0f53-6906-da9f-03e90e03afc6'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='4e9801a0-002a-a870-8555-f9123030af59' order by rp.startdate,rp.enddate) - sper ) prp where id='86c57b67-0f53-6906-da9f-03e90e03afc6'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-05-01') and date('2021-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='4e9801a0-002a-a870-8555-f9123030af59' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='4e9801a0-002a-a870-8555-f9123030af59' and sr.daydate between date('2021-05-01') and date(date_trunc('week',date('2021-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '4e9801a0-002a-a870-8555-f9123030af59' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days') - --where id_staff= '4e9801a0-002a-a870-8555-f9123030af59' and daydate between date('2021-05-01') and date('2021-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '86c57b67-0f53-6906-da9f-03e90e03afc6') - where pd.id_staff='4e9801a0-002a-a870-8555-f9123030af59' and pd.daydate between date('2021-05-01') and date('2021-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '4e9801a0-002a-a870-8555-f9123030af59' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'4e9801a0-002a-a870-8555-f9123030af59' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='4e9801a0-002a-a870-8555-f9123030af59' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'4e9801a0-002a-a870-8555-f9123030af59' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='4e9801a0-002a-a870-8555-f9123030af59' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='4e9801a0-002a-a870-8555-f9123030af59' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='4e9801a0-002a-a870-8555-f9123030af59' order by rp.startdate,rp.enddate) - sper ) prp where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-09-01') and date('2021-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='4e9801a0-002a-a870-8555-f9123030af59' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='4e9801a0-002a-a870-8555-f9123030af59' and sr.daydate between date('2021-09-01') and date(date_trunc('week',date('2021-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '4e9801a0-002a-a870-8555-f9123030af59' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days') - --where id_staff= '4e9801a0-002a-a870-8555-f9123030af59' and daydate between date('2021-09-01') and date('2021-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=5,last44date=date('2021-11-15'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '90632f2f-6134-65d8-bfd0-ab2ece5f7f7f') - where pd.id_staff='4e9801a0-002a-a870-8555-f9123030af59' and pd.daydate between date('2021-09-01') and date('2021-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '4e9801a0-002a-a870-8555-f9123030af59' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'4e9801a0-002a-a870-8555-f9123030af59' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='4e9801a0-002a-a870-8555-f9123030af59' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'4e9801a0-002a-a870-8555-f9123030af59' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='4e9801a0-002a-a870-8555-f9123030af59' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='4e9801a0-002a-a870-8555-f9123030af59' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='4e9801a0-002a-a870-8555-f9123030af59' order by rp.startdate,rp.enddate) - sper ) prp where id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2022-01-01') and date('2022-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='4e9801a0-002a-a870-8555-f9123030af59' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='4e9801a0-002a-a870-8555-f9123030af59' and sr.daydate between date('2022-01-01') and date(date_trunc('week',date('2022-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '4e9801a0-002a-a870-8555-f9123030af59' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-04-30')) + interval '6 days') - --where id_staff= '4e9801a0-002a-a870-8555-f9123030af59' and daydate between date('2022-01-01') and date('2022-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a0f71278-f95c-bffd-8dd7-d502f0cc88aa') - where pd.id_staff='4e9801a0-002a-a870-8555-f9123030af59' and pd.daydate between date('2022-01-01') and date('2022-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '4e9801a0-002a-a870-8555-f9123030af59' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='a565664b-07b7-a90d-be8b-14a585d7766d'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'4e9801a0-002a-a870-8555-f9123030af59' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='4e9801a0-002a-a870-8555-f9123030af59' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'4e9801a0-002a-a870-8555-f9123030af59' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='4e9801a0-002a-a870-8555-f9123030af59' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='4e9801a0-002a-a870-8555-f9123030af59' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='a565664b-07b7-a90d-be8b-14a585d7766d'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='4e9801a0-002a-a870-8555-f9123030af59' order by rp.startdate,rp.enddate) - sper ) prp where id='a565664b-07b7-a90d-be8b-14a585d7766d'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and daydate between date(date_trunc('week',date('2022-05-01'))) and date(date_trunc('week',date('2022-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and daydate between date(date_trunc('week',date('2022-05-01'))) and date(date_trunc('week',date('2022-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2022-05-01') and date('2022-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='4e9801a0-002a-a870-8555-f9123030af59' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='4e9801a0-002a-a870-8555-f9123030af59' and sr.daydate between date('2022-05-01') and date(date_trunc('week',date('2022-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '4e9801a0-002a-a870-8555-f9123030af59' and daydate between date(date_trunc('week',date('2022-05-01'))) and date(date_trunc('week',date('2022-08-31')) + interval '6 days') - --where id_staff= '4e9801a0-002a-a870-8555-f9123030af59' and daydate between date('2022-05-01') and date('2022-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a565664b-07b7-a90d-be8b-14a585d7766d') - where pd.id_staff='4e9801a0-002a-a870-8555-f9123030af59' and pd.daydate between date('2022-05-01') and date('2022-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '4e9801a0-002a-a870-8555-f9123030af59' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'4e9801a0-002a-a870-8555-f9123030af59' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='4e9801a0-002a-a870-8555-f9123030af59' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'4e9801a0-002a-a870-8555-f9123030af59' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='4e9801a0-002a-a870-8555-f9123030af59' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='4e9801a0-002a-a870-8555-f9123030af59' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='4e9801a0-002a-a870-8555-f9123030af59' order by rp.startdate,rp.enddate) - sper ) prp where id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and daydate between date(date_trunc('week',date('2022-09-01'))) and date(date_trunc('week',date('2022-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and daydate between date(date_trunc('week',date('2022-09-01'))) and date(date_trunc('week',date('2022-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2022-09-01') and date('2022-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='4e9801a0-002a-a870-8555-f9123030af59' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='4e9801a0-002a-a870-8555-f9123030af59' and sr.daydate between date('2022-09-01') and date(date_trunc('week',date('2022-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '4e9801a0-002a-a870-8555-f9123030af59' and daydate between date(date_trunc('week',date('2022-09-01'))) and date(date_trunc('week',date('2022-12-31')) + interval '6 days') - --where id_staff= '4e9801a0-002a-a870-8555-f9123030af59' and daydate between date('2022-09-01') and date('2022-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '9a1ca2f0-c1d7-8652-69d9-9dc25057efe8') - where pd.id_staff='4e9801a0-002a-a870-8555-f9123030af59' and pd.daydate between date('2022-09-01') and date('2022-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '4e9801a0-002a-a870-8555-f9123030af59' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='5d40fe41-c607-b65b-0866-30298ba9833e'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'4e9801a0-002a-a870-8555-f9123030af59' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='4e9801a0-002a-a870-8555-f9123030af59' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'4e9801a0-002a-a870-8555-f9123030af59' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='4e9801a0-002a-a870-8555-f9123030af59' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='4e9801a0-002a-a870-8555-f9123030af59' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='5d40fe41-c607-b65b-0866-30298ba9833e'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='4e9801a0-002a-a870-8555-f9123030af59' order by rp.startdate,rp.enddate) - sper ) prp where id='5d40fe41-c607-b65b-0866-30298ba9833e'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and daydate between date(date_trunc('week',date('2023-01-01'))) and date(date_trunc('week',date('2023-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and daydate between date(date_trunc('week',date('2023-01-01'))) and date(date_trunc('week',date('2023-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2023-01-01') and date('2023-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='4e9801a0-002a-a870-8555-f9123030af59' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='4e9801a0-002a-a870-8555-f9123030af59' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2023-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='4e9801a0-002a-a870-8555-f9123030af59' and sr.daydate between date('2023-01-01') and date(date_trunc('week',date('2023-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '4e9801a0-002a-a870-8555-f9123030af59' and daydate between date(date_trunc('week',date('2023-01-01'))) and date(date_trunc('week',date('2023-04-30')) + interval '6 days') - --where id_staff= '4e9801a0-002a-a870-8555-f9123030af59' and daydate between date('2023-01-01') and date('2023-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '5d40fe41-c607-b65b-0866-30298ba9833e') - where pd.id_staff='4e9801a0-002a-a870-8555-f9123030af59' and pd.daydate between date('2023-01-01') and date('2023-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '4e9801a0-002a-a870-8555-f9123030af59' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id from alicehartmann.reportperiod order by startdate,enddate; -QUERYARRAY: select id,startdate,enddate from alicehartmann.reportperiod where -startdate >= date((select min(startdate) from alicehartmann.staffcontract where id_staff='213e619d-1149-69d4-de57-997a16cd3d21')) -or date((select min(startdate) from alicehartmann.staffcontract where id_staff='213e619d-1149-69d4-de57-997a16cd3d21')) between startdate and enddate order by startdate,enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='2cdf9b30-bbdf-0a25-a736-1c569b116069'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'213e619d-1149-69d4-de57-997a16cd3d21' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'213e619d-1149-69d4-de57-997a16cd3d21' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='213e619d-1149-69d4-de57-997a16cd3d21' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('2cdf9b30-bbdf-0a25-a736-1c569b116069','213e619d-1149-69d4-de57-997a16cd3d21') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='86c57b67-0f53-6906-da9f-03e90e03afc6'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'213e619d-1149-69d4-de57-997a16cd3d21' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'213e619d-1149-69d4-de57-997a16cd3d21' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='213e619d-1149-69d4-de57-997a16cd3d21' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('86c57b67-0f53-6906-da9f-03e90e03afc6','213e619d-1149-69d4-de57-997a16cd3d21') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'213e619d-1149-69d4-de57-997a16cd3d21' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'213e619d-1149-69d4-de57-997a16cd3d21' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='213e619d-1149-69d4-de57-997a16cd3d21' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('90632f2f-6134-65d8-bfd0-ab2ece5f7f7f','213e619d-1149-69d4-de57-997a16cd3d21') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'213e619d-1149-69d4-de57-997a16cd3d21' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'213e619d-1149-69d4-de57-997a16cd3d21' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='213e619d-1149-69d4-de57-997a16cd3d21' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('a0f71278-f95c-bffd-8dd7-d502f0cc88aa','213e619d-1149-69d4-de57-997a16cd3d21') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='a565664b-07b7-a90d-be8b-14a585d7766d'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'213e619d-1149-69d4-de57-997a16cd3d21' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'213e619d-1149-69d4-de57-997a16cd3d21' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='213e619d-1149-69d4-de57-997a16cd3d21' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('a565664b-07b7-a90d-be8b-14a585d7766d','213e619d-1149-69d4-de57-997a16cd3d21') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'213e619d-1149-69d4-de57-997a16cd3d21' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'213e619d-1149-69d4-de57-997a16cd3d21' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='213e619d-1149-69d4-de57-997a16cd3d21' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('9a1ca2f0-c1d7-8652-69d9-9dc25057efe8','213e619d-1149-69d4-de57-997a16cd3d21') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='5d40fe41-c607-b65b-0866-30298ba9833e'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'213e619d-1149-69d4-de57-997a16cd3d21' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'213e619d-1149-69d4-de57-997a16cd3d21' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='213e619d-1149-69d4-de57-997a16cd3d21' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('5d40fe41-c607-b65b-0866-30298ba9833e','213e619d-1149-69d4-de57-997a16cd3d21') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select reportperiodunit,reportperiodlength from public.companies where schemata='alicehartmann' -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' - ) scx where startdate < enddate and id='2cdf9b30-bbdf-0a25-a736-1c569b116069' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-01-01'),date('2021-04-30'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 86 as maxdays,86 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from alicehartmann.staffreportperioddays - where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date('2021-01-01') and date('2021-04-30') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-04-30') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-04-30')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from alicehartmann.staffcontract where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update alicehartmann.staffreportperiod set maxdays=86,contracthours='688:00:00' where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod='2cdf9b30-bbdf-0a25-a736-1c569b116069'; -QUERY: select * from alicehartmann.reportperiod where id='2cdf9b30-bbdf-0a25-a736-1c569b116069'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by rp.startdate,rp.enddate) - sper ) prp where id='2cdf9b30-bbdf-0a25-a736-1c569b116069'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-01-01') and date('2021-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and sr.daydate between date('2021-01-01') and date(date_trunc('week',date('2021-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days') - --where id_staff= '213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date('2021-01-01') and date('2021-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '2cdf9b30-bbdf-0a25-a736-1c569b116069') - where pd.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and pd.daydate between date('2021-01-01') and date('2021-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '213e619d-1149-69d4-de57-997a16cd3d21' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' - ) scx where startdate < enddate and id='86c57b67-0f53-6906-da9f-03e90e03afc6' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-05-01'),date('2021-08-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 87 as maxdays,87 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from alicehartmann.staffreportperioddays - where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date('2021-05-01') and date('2021-08-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-08-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-08-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from alicehartmann.staffcontract where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update alicehartmann.staffreportperiod set maxdays=87,contracthours='696:00:00' where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod='86c57b67-0f53-6906-da9f-03e90e03afc6'; -QUERY: select * from alicehartmann.reportperiod where id='86c57b67-0f53-6906-da9f-03e90e03afc6'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by rp.startdate,rp.enddate) - sper ) prp where id='86c57b67-0f53-6906-da9f-03e90e03afc6'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='2cdf9b30-bbdf-0a25-a736-1c569b116069' and id_staff='213e619d-1149-69d4-de57-997a16cd3d21'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-05-01') and date('2021-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and sr.daydate between date('2021-05-01') and date(date_trunc('week',date('2021-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days') - --where id_staff= '213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date('2021-05-01') and date('2021-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=7,last44date=date('2021-08-30'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '86c57b67-0f53-6906-da9f-03e90e03afc6') - where pd.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and pd.daydate between date('2021-05-01') and date('2021-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '213e619d-1149-69d4-de57-997a16cd3d21' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' - ) scx where startdate < enddate and id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-09-01'),date('2021-12-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 88 as maxdays,88 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from alicehartmann.staffreportperioddays - where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date('2021-09-01') and date('2021-12-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-12-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-12-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from alicehartmann.staffcontract where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update alicehartmann.staffreportperiod set maxdays=88,contracthours='704:00:00' where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select * from alicehartmann.reportperiod where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by rp.startdate,rp.enddate) - sper ) prp where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='86c57b67-0f53-6906-da9f-03e90e03afc6' and id_staff='213e619d-1149-69d4-de57-997a16cd3d21'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-09-01') and date('2021-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,7+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and sr.daydate between date('2021-08-30') and date(date_trunc('week',date('2021-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days') - --where id_staff= '213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date('2021-09-01') and date('2021-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=1,status44hcount=4,last44date=date('2021-12-27'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '90632f2f-6134-65d8-bfd0-ab2ece5f7f7f') - where pd.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and pd.daydate between date('2021-09-01') and date('2021-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '213e619d-1149-69d4-de57-997a16cd3d21' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' - ) scx where startdate < enddate and id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2022-01-01'),date('2022-04-30'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 85 as maxdays,85 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from alicehartmann.staffreportperioddays - where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date('2022-01-01') and date('2022-04-30') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2022-04-30') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2022-04-30')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from alicehartmann.staffcontract where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update alicehartmann.staffreportperiod set maxdays=85,contracthours='680:00:00' where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -QUERY: select * from alicehartmann.reportperiod where id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by rp.startdate,rp.enddate) - sper ) prp where id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f' and id_staff='213e619d-1149-69d4-de57-997a16cd3d21'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2022-01-01') and date('2022-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,4+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and sr.daydate between date('2021-12-27') and date(date_trunc('week',date('2022-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-04-30')) + interval '6 days') - --where id_staff= '213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date('2022-01-01') and date('2022-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=1,status44hcount=7,last44date=date('2022-04-25'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a0f71278-f95c-bffd-8dd7-d502f0cc88aa') - where pd.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and pd.daydate between date('2022-01-01') and date('2022-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '213e619d-1149-69d4-de57-997a16cd3d21' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' - ) scx where startdate < enddate and id='a565664b-07b7-a90d-be8b-14a585d7766d' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2022-05-01'),date('2022-08-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 88 as maxdays,88 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from alicehartmann.staffreportperioddays - where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date('2022-05-01') and date('2022-08-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2022-08-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2022-08-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from alicehartmann.staffcontract where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update alicehartmann.staffreportperiod set maxdays=88,contracthours='704:00:00' where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod='a565664b-07b7-a90d-be8b-14a585d7766d'; -QUERY: select * from alicehartmann.reportperiod where id='a565664b-07b7-a90d-be8b-14a585d7766d'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by rp.startdate,rp.enddate) - sper ) prp where id='a565664b-07b7-a90d-be8b-14a585d7766d'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2022-05-01'))) and date(date_trunc('week',date('2022-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2022-05-01'))) and date(date_trunc('week',date('2022-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='a0f71278-f95c-bffd-8dd7-d502f0cc88aa' and id_staff='213e619d-1149-69d4-de57-997a16cd3d21'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2022-05-01') and date('2022-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,7+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and sr.daydate between date('2022-04-25') and date(date_trunc('week',date('2022-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2022-05-01'))) and date(date_trunc('week',date('2022-08-31')) + interval '6 days') - --where id_staff= '213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date('2022-05-01') and date('2022-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=1,status44hcount=0,last44date=date('2022-05-02'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a565664b-07b7-a90d-be8b-14a585d7766d') - where pd.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and pd.daydate between date('2022-05-01') and date('2022-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '213e619d-1149-69d4-de57-997a16cd3d21' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' - ) scx where startdate < enddate and id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2022-09-01'),date('2022-12-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 87 as maxdays,87 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from alicehartmann.staffreportperioddays - where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date('2022-09-01') and date('2022-12-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2022-12-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2022-12-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from alicehartmann.staffcontract where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update alicehartmann.staffreportperiod set maxdays=87,contracthours='696:00:00' where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -QUERY: select * from alicehartmann.reportperiod where id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by rp.startdate,rp.enddate) - sper ) prp where id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2022-09-01'))) and date(date_trunc('week',date('2022-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2022-09-01'))) and date(date_trunc('week',date('2022-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='a565664b-07b7-a90d-be8b-14a585d7766d' and id_staff='213e619d-1149-69d4-de57-997a16cd3d21'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2022-09-01') and date('2022-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,0+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and sr.daydate between date('2022-05-02') and date(date_trunc('week',date('2022-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2022-09-01'))) and date(date_trunc('week',date('2022-12-31')) + interval '6 days') - --where id_staff= '213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date('2022-09-01') and date('2022-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '9a1ca2f0-c1d7-8652-69d9-9dc25057efe8') - where pd.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and pd.daydate between date('2022-09-01') and date('2022-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '213e619d-1149-69d4-de57-997a16cd3d21' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' - ) scx where startdate < enddate and id='5d40fe41-c607-b65b-0866-30298ba9833e' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2023-01-01'),date('2023-04-30'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 85 as maxdays,85 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from alicehartmann.staffreportperioddays - where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date('2023-01-01') and date('2023-04-30') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2023-04-30') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2023-04-30')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from alicehartmann.staffcontract where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update alicehartmann.staffreportperiod set maxdays=85,contracthours='680:00:00' where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod='5d40fe41-c607-b65b-0866-30298ba9833e'; -QUERY: select * from alicehartmann.reportperiod where id='5d40fe41-c607-b65b-0866-30298ba9833e'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by rp.startdate,rp.enddate) - sper ) prp where id='5d40fe41-c607-b65b-0866-30298ba9833e'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2023-01-01'))) and date(date_trunc('week',date('2023-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2023-01-01'))) and date(date_trunc('week',date('2023-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8' and id_staff='213e619d-1149-69d4-de57-997a16cd3d21'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2023-01-01') and date('2023-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2023-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and sr.daydate between date('2023-01-01') and date(date_trunc('week',date('2023-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2023-01-01'))) and date(date_trunc('week',date('2023-04-30')) + interval '6 days') - --where id_staff= '213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date('2023-01-01') and date('2023-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '5d40fe41-c607-b65b-0866-30298ba9833e') - where pd.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and pd.daydate between date('2023-01-01') and date('2023-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '213e619d-1149-69d4-de57-997a16cd3d21' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -EXEC: insert into alicehartmann.staffvacancyyear (id_staff,vacyear) - select id_staff,to_char(daydate,'YYYY')::int4 as vyear from alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' group by id_staff,vyear order by id_staff,vyear - on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='2cdf9b30-bbdf-0a25-a736-1c569b116069'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'213e619d-1149-69d4-de57-997a16cd3d21' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'213e619d-1149-69d4-de57-997a16cd3d21' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='213e619d-1149-69d4-de57-997a16cd3d21' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='2cdf9b30-bbdf-0a25-a736-1c569b116069'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by rp.startdate,rp.enddate) - sper ) prp where id='2cdf9b30-bbdf-0a25-a736-1c569b116069'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-01-01') and date('2021-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and sr.daydate between date('2021-01-01') and date(date_trunc('week',date('2021-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days') - --where id_staff= '213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date('2021-01-01') and date('2021-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '2cdf9b30-bbdf-0a25-a736-1c569b116069') - where pd.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and pd.daydate between date('2021-01-01') and date('2021-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '213e619d-1149-69d4-de57-997a16cd3d21' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='86c57b67-0f53-6906-da9f-03e90e03afc6'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'213e619d-1149-69d4-de57-997a16cd3d21' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'213e619d-1149-69d4-de57-997a16cd3d21' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='213e619d-1149-69d4-de57-997a16cd3d21' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='86c57b67-0f53-6906-da9f-03e90e03afc6'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by rp.startdate,rp.enddate) - sper ) prp where id='86c57b67-0f53-6906-da9f-03e90e03afc6'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='2cdf9b30-bbdf-0a25-a736-1c569b116069' and id_staff='213e619d-1149-69d4-de57-997a16cd3d21'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-05-01') and date('2021-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and sr.daydate between date('2021-05-01') and date(date_trunc('week',date('2021-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days') - --where id_staff= '213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date('2021-05-01') and date('2021-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=7,last44date=date('2021-08-30'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '86c57b67-0f53-6906-da9f-03e90e03afc6') - where pd.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and pd.daydate between date('2021-05-01') and date('2021-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '213e619d-1149-69d4-de57-997a16cd3d21' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'213e619d-1149-69d4-de57-997a16cd3d21' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'213e619d-1149-69d4-de57-997a16cd3d21' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='213e619d-1149-69d4-de57-997a16cd3d21' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by rp.startdate,rp.enddate) - sper ) prp where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='86c57b67-0f53-6906-da9f-03e90e03afc6' and id_staff='213e619d-1149-69d4-de57-997a16cd3d21'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-09-01') and date('2021-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,7+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and sr.daydate between date('2021-08-30') and date(date_trunc('week',date('2021-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days') - --where id_staff= '213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date('2021-09-01') and date('2021-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=1,status44hcount=4,last44date=date('2021-12-27'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '90632f2f-6134-65d8-bfd0-ab2ece5f7f7f') - where pd.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and pd.daydate between date('2021-09-01') and date('2021-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '213e619d-1149-69d4-de57-997a16cd3d21' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'213e619d-1149-69d4-de57-997a16cd3d21' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'213e619d-1149-69d4-de57-997a16cd3d21' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='213e619d-1149-69d4-de57-997a16cd3d21' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by rp.startdate,rp.enddate) - sper ) prp where id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f' and id_staff='213e619d-1149-69d4-de57-997a16cd3d21'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2022-01-01') and date('2022-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,4+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and sr.daydate between date('2021-12-27') and date(date_trunc('week',date('2022-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-04-30')) + interval '6 days') - --where id_staff= '213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date('2022-01-01') and date('2022-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=1,status44hcount=7,last44date=date('2022-04-25'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a0f71278-f95c-bffd-8dd7-d502f0cc88aa') - where pd.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and pd.daydate between date('2022-01-01') and date('2022-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '213e619d-1149-69d4-de57-997a16cd3d21' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='a565664b-07b7-a90d-be8b-14a585d7766d'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'213e619d-1149-69d4-de57-997a16cd3d21' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'213e619d-1149-69d4-de57-997a16cd3d21' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='213e619d-1149-69d4-de57-997a16cd3d21' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='a565664b-07b7-a90d-be8b-14a585d7766d'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by rp.startdate,rp.enddate) - sper ) prp where id='a565664b-07b7-a90d-be8b-14a585d7766d'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2022-05-01'))) and date(date_trunc('week',date('2022-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2022-05-01'))) and date(date_trunc('week',date('2022-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='a0f71278-f95c-bffd-8dd7-d502f0cc88aa' and id_staff='213e619d-1149-69d4-de57-997a16cd3d21'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2022-05-01') and date('2022-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,7+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and sr.daydate between date('2022-04-25') and date(date_trunc('week',date('2022-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2022-05-01'))) and date(date_trunc('week',date('2022-08-31')) + interval '6 days') - --where id_staff= '213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date('2022-05-01') and date('2022-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=1,status44hcount=0,last44date=date('2022-05-02'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a565664b-07b7-a90d-be8b-14a585d7766d') - where pd.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and pd.daydate between date('2022-05-01') and date('2022-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '213e619d-1149-69d4-de57-997a16cd3d21' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'213e619d-1149-69d4-de57-997a16cd3d21' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'213e619d-1149-69d4-de57-997a16cd3d21' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='213e619d-1149-69d4-de57-997a16cd3d21' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by rp.startdate,rp.enddate) - sper ) prp where id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2022-09-01'))) and date(date_trunc('week',date('2022-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2022-09-01'))) and date(date_trunc('week',date('2022-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='a565664b-07b7-a90d-be8b-14a585d7766d' and id_staff='213e619d-1149-69d4-de57-997a16cd3d21'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2022-09-01') and date('2022-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,0+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and sr.daydate between date('2022-05-02') and date(date_trunc('week',date('2022-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2022-09-01'))) and date(date_trunc('week',date('2022-12-31')) + interval '6 days') - --where id_staff= '213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date('2022-09-01') and date('2022-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '9a1ca2f0-c1d7-8652-69d9-9dc25057efe8') - where pd.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and pd.daydate between date('2022-09-01') and date('2022-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '213e619d-1149-69d4-de57-997a16cd3d21' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='5d40fe41-c607-b65b-0866-30298ba9833e'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'213e619d-1149-69d4-de57-997a16cd3d21' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2020-12-28'))) as firstday , date(date_trunc('week',date('2023-04-30')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'213e619d-1149-69d4-de57-997a16cd3d21' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2020-12-28'::timestamp,'2023-04-30'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and (daydate > date('2023-04-30') or daydate < date('2020-12-28')) - OR (id_staff='213e619d-1149-69d4-de57-997a16cd3d21' AND daydate not between date('2020-12-28') and date('2023-04-30')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='5d40fe41-c607-b65b-0866-30298ba9833e'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by rp.startdate,rp.enddate) - sper ) prp where id='5d40fe41-c607-b65b-0866-30298ba9833e'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2023-01-01'))) and date(date_trunc('week',date('2023-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2023-01-01'))) and date(date_trunc('week',date('2023-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8' and id_staff='213e619d-1149-69d4-de57-997a16cd3d21'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2023-01-01') and date('2023-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='213e619d-1149-69d4-de57-997a16cd3d21' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2023-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and sr.daydate between date('2023-01-01') and date(date_trunc('week',date('2023-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date(date_trunc('week',date('2023-01-01'))) and date(date_trunc('week',date('2023-04-30')) + interval '6 days') - --where id_staff= '213e619d-1149-69d4-de57-997a16cd3d21' and daydate between date('2023-01-01') and date('2023-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '5d40fe41-c607-b65b-0866-30298ba9833e') - where pd.id_staff='213e619d-1149-69d4-de57-997a16cd3d21' and pd.daydate between date('2023-01-01') and date('2023-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '213e619d-1149-69d4-de57-997a16cd3d21' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id from alicehartmann.reportperiod order by startdate,enddate; -QUERYARRAY: select id,startdate,enddate from alicehartmann.reportperiod where -startdate >= date((select min(startdate) from alicehartmann.staffcontract where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3')) -or date((select min(startdate) from alicehartmann.staffcontract where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3')) between startdate and enddate order by startdate,enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='86c57b67-0f53-6906-da9f-03e90e03afc6'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-05-17'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-05-17'::timestamp,'2021-08-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-09-27'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and (daydate > date('2021-11-14') or daydate < date('2021-05-17')) - OR (id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' AND daydate not between date('2021-05-17') and date('2021-08-31') AND daydate not between date('2021-09-27') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('86c57b67-0f53-6906-da9f-03e90e03afc6','5c9b540e-6a25-433b-6522-9c6c4f36c9d3') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-05-17'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-05-17'::timestamp,'2021-08-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-09-27'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and (daydate > date('2021-11-14') or daydate < date('2021-05-17')) - OR (id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' AND daydate not between date('2021-05-17') and date('2021-08-31') AND daydate not between date('2021-09-27') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('90632f2f-6134-65d8-bfd0-ab2ece5f7f7f','5c9b540e-6a25-433b-6522-9c6c4f36c9d3') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-05-17'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-05-17'::timestamp,'2021-08-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-09-27'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and (daydate > date('2021-11-14') or daydate < date('2021-05-17')) - OR (id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' AND daydate not between date('2021-05-17') and date('2021-08-31') AND daydate not between date('2021-09-27') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('a0f71278-f95c-bffd-8dd7-d502f0cc88aa','5c9b540e-6a25-433b-6522-9c6c4f36c9d3') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='a565664b-07b7-a90d-be8b-14a585d7766d'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-05-17'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-05-17'::timestamp,'2021-08-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-09-27'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and (daydate > date('2021-11-14') or daydate < date('2021-05-17')) - OR (id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' AND daydate not between date('2021-05-17') and date('2021-08-31') AND daydate not between date('2021-09-27') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('a565664b-07b7-a90d-be8b-14a585d7766d','5c9b540e-6a25-433b-6522-9c6c4f36c9d3') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-05-17'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-05-17'::timestamp,'2021-08-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-09-27'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and (daydate > date('2021-11-14') or daydate < date('2021-05-17')) - OR (id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' AND daydate not between date('2021-05-17') and date('2021-08-31') AND daydate not between date('2021-09-27') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('9a1ca2f0-c1d7-8652-69d9-9dc25057efe8','5c9b540e-6a25-433b-6522-9c6c4f36c9d3') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='5d40fe41-c607-b65b-0866-30298ba9833e'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-05-17'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-05-17'::timestamp,'2021-08-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-09-27'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and (daydate > date('2021-11-14') or daydate < date('2021-05-17')) - OR (id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' AND daydate not between date('2021-05-17') and date('2021-08-31') AND daydate not between date('2021-09-27') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('5d40fe41-c607-b65b-0866-30298ba9833e','5c9b540e-6a25-433b-6522-9c6c4f36c9d3') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select reportperiodunit,reportperiodlength from public.companies where schemata='alicehartmann' -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' - ) scx where startdate < enddate and id='86c57b67-0f53-6906-da9f-03e90e03afc6' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-05-17'),date('2021-08-31'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 77 as maxdays,77 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from alicehartmann.staffreportperioddays - where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date('2021-05-01') and date('2021-08-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-08-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-08-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from alicehartmann.staffcontract where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update alicehartmann.staffreportperiod set maxdays=77,contracthours='616:00:00' where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and id_reportperiod='86c57b67-0f53-6906-da9f-03e90e03afc6'; -QUERY: select * from alicehartmann.reportperiod where id='86c57b67-0f53-6906-da9f-03e90e03afc6'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' order by rp.startdate,rp.enddate) - sper ) prp where id='86c57b67-0f53-6906-da9f-03e90e03afc6'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-05-01') and date('2021-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and sr.daydate between date('2021-05-01') and date(date_trunc('week',date('2021-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days') - --where id_staff= '5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date('2021-05-01') and date('2021-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=1,status44hcount=6,last44date=date('2021-08-23'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '86c57b67-0f53-6906-da9f-03e90e03afc6') - where pd.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and pd.daydate between date('2021-05-01') and date('2021-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '5c9b540e-6a25-433b-6522-9c6c4f36c9d3' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' - ) scx where startdate < enddate and id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-09-27'),date('2021-11-09'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 32 as maxdays,32 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from alicehartmann.staffreportperioddays - where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date('2021-09-01') and date('2021-12-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-12-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-12-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from alicehartmann.staffcontract where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update alicehartmann.staffreportperiod set maxdays=32,contracthours='256:00:00' where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and id_reportperiod='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select * from alicehartmann.reportperiod where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' order by rp.startdate,rp.enddate) - sper ) prp where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='86c57b67-0f53-6906-da9f-03e90e03afc6' and id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-09-01') and date('2021-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,6+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and sr.daydate between date('2021-08-23') and date(date_trunc('week',date('2021-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days') - --where id_staff= '5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date('2021-09-01') and date('2021-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=1,status44hcount=3,last44date=date('2021-11-15'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '90632f2f-6134-65d8-bfd0-ab2ece5f7f7f') - where pd.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and pd.daydate between date('2021-09-01') and date('2021-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '5c9b540e-6a25-433b-6522-9c6c4f36c9d3' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' - ) scx where startdate < enddate and id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa' order by startdate,enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' - ) scx where startdate < enddate and id='a565664b-07b7-a90d-be8b-14a585d7766d' order by startdate,enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' - ) scx where startdate < enddate and id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8' order by startdate,enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' - ) scx where startdate < enddate and id='5d40fe41-c607-b65b-0866-30298ba9833e' order by startdate,enddate; -EXEC: insert into alicehartmann.staffvacancyyear (id_staff,vacyear) - select id_staff,to_char(daydate,'YYYY')::int4 as vyear from alicehartmann.staffreportperioddays where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' group by id_staff,vyear order by id_staff,vyear - on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='2cdf9b30-bbdf-0a25-a736-1c569b116069'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-05-17'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-05-17'::timestamp,'2021-08-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-09-27'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and (daydate > date('2021-11-14') or daydate < date('2021-05-17')) - OR (id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' AND daydate not between date('2021-05-17') and date('2021-08-31') AND daydate not between date('2021-09-27') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='2cdf9b30-bbdf-0a25-a736-1c569b116069'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' order by rp.startdate,rp.enddate) - sper ) prp where id='2cdf9b30-bbdf-0a25-a736-1c569b116069'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-01-01') and date('2021-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and sr.daydate between date('2021-01-01') and date(date_trunc('week',date('2021-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days') - --where id_staff= '5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date('2021-01-01') and date('2021-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '2cdf9b30-bbdf-0a25-a736-1c569b116069') - where pd.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and pd.daydate between date('2021-01-01') and date('2021-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '5c9b540e-6a25-433b-6522-9c6c4f36c9d3' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='86c57b67-0f53-6906-da9f-03e90e03afc6'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-05-17'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-05-17'::timestamp,'2021-08-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-09-27'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and (daydate > date('2021-11-14') or daydate < date('2021-05-17')) - OR (id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' AND daydate not between date('2021-05-17') and date('2021-08-31') AND daydate not between date('2021-09-27') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='86c57b67-0f53-6906-da9f-03e90e03afc6'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' order by rp.startdate,rp.enddate) - sper ) prp where id='86c57b67-0f53-6906-da9f-03e90e03afc6'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-05-01') and date('2021-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and sr.daydate between date('2021-05-01') and date(date_trunc('week',date('2021-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days') - --where id_staff= '5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date('2021-05-01') and date('2021-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=1,status44hcount=6,last44date=date('2021-08-23'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '86c57b67-0f53-6906-da9f-03e90e03afc6') - where pd.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and pd.daydate between date('2021-05-01') and date('2021-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '5c9b540e-6a25-433b-6522-9c6c4f36c9d3' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-05-17'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-05-17'::timestamp,'2021-08-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-09-27'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and (daydate > date('2021-11-14') or daydate < date('2021-05-17')) - OR (id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' AND daydate not between date('2021-05-17') and date('2021-08-31') AND daydate not between date('2021-09-27') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' order by rp.startdate,rp.enddate) - sper ) prp where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select * from alicehartmann.staffreportperiod where id_reportperiod='86c57b67-0f53-6906-da9f-03e90e03afc6' and id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3'; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-09-01') and date('2021-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,6+sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and sr.daydate between date('2021-08-23') and date(date_trunc('week',date('2021-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days') - --where id_staff= '5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date('2021-09-01') and date('2021-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=1,status44hcount=3,last44date=date('2021-11-15'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '90632f2f-6134-65d8-bfd0-ab2ece5f7f7f') - where pd.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and pd.daydate between date('2021-09-01') and date('2021-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '5c9b540e-6a25-433b-6522-9c6c4f36c9d3' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-05-17'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-05-17'::timestamp,'2021-08-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-09-27'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and (daydate > date('2021-11-14') or daydate < date('2021-05-17')) - OR (id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' AND daydate not between date('2021-05-17') and date('2021-08-31') AND daydate not between date('2021-09-27') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' order by rp.startdate,rp.enddate) - sper ) prp where id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2022-01-01') and date('2022-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and sr.daydate between date('2022-01-01') and date(date_trunc('week',date('2022-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-04-30')) + interval '6 days') - --where id_staff= '5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date('2022-01-01') and date('2022-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a0f71278-f95c-bffd-8dd7-d502f0cc88aa') - where pd.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and pd.daydate between date('2022-01-01') and date('2022-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '5c9b540e-6a25-433b-6522-9c6c4f36c9d3' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='a565664b-07b7-a90d-be8b-14a585d7766d'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-05-17'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-05-17'::timestamp,'2021-08-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-09-27'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and (daydate > date('2021-11-14') or daydate < date('2021-05-17')) - OR (id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' AND daydate not between date('2021-05-17') and date('2021-08-31') AND daydate not between date('2021-09-27') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='a565664b-07b7-a90d-be8b-14a585d7766d'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' order by rp.startdate,rp.enddate) - sper ) prp where id='a565664b-07b7-a90d-be8b-14a585d7766d'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date(date_trunc('week',date('2022-05-01'))) and date(date_trunc('week',date('2022-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date(date_trunc('week',date('2022-05-01'))) and date(date_trunc('week',date('2022-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2022-05-01') and date('2022-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and sr.daydate between date('2022-05-01') and date(date_trunc('week',date('2022-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date(date_trunc('week',date('2022-05-01'))) and date(date_trunc('week',date('2022-08-31')) + interval '6 days') - --where id_staff= '5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date('2022-05-01') and date('2022-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a565664b-07b7-a90d-be8b-14a585d7766d') - where pd.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and pd.daydate between date('2022-05-01') and date('2022-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '5c9b540e-6a25-433b-6522-9c6c4f36c9d3' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-05-17'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-05-17'::timestamp,'2021-08-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-09-27'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and (daydate > date('2021-11-14') or daydate < date('2021-05-17')) - OR (id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' AND daydate not between date('2021-05-17') and date('2021-08-31') AND daydate not between date('2021-09-27') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' order by rp.startdate,rp.enddate) - sper ) prp where id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date(date_trunc('week',date('2022-09-01'))) and date(date_trunc('week',date('2022-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date(date_trunc('week',date('2022-09-01'))) and date(date_trunc('week',date('2022-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2022-09-01') and date('2022-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and sr.daydate between date('2022-09-01') and date(date_trunc('week',date('2022-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date(date_trunc('week',date('2022-09-01'))) and date(date_trunc('week',date('2022-12-31')) + interval '6 days') - --where id_staff= '5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date('2022-09-01') and date('2022-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '9a1ca2f0-c1d7-8652-69d9-9dc25057efe8') - where pd.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and pd.daydate between date('2022-09-01') and date('2022-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '5c9b540e-6a25-433b-6522-9c6c4f36c9d3' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='5d40fe41-c607-b65b-0866-30298ba9833e'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-05-17'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-05-17'::timestamp,'2021-08-31'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'5c9b540e-6a25-433b-6522-9c6c4f36c9d3' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-09-27'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and (daydate > date('2021-11-14') or daydate < date('2021-05-17')) - OR (id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' AND daydate not between date('2021-05-17') and date('2021-08-31') AND daydate not between date('2021-09-27') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='5d40fe41-c607-b65b-0866-30298ba9833e'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' order by rp.startdate,rp.enddate) - sper ) prp where id='5d40fe41-c607-b65b-0866-30298ba9833e'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date(date_trunc('week',date('2023-01-01'))) and date(date_trunc('week',date('2023-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date(date_trunc('week',date('2023-01-01'))) and date(date_trunc('week',date('2023-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2023-01-01') and date('2023-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2023-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and sr.daydate between date('2023-01-01') and date(date_trunc('week',date('2023-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date(date_trunc('week',date('2023-01-01'))) and date(date_trunc('week',date('2023-04-30')) + interval '6 days') - --where id_staff= '5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and daydate between date('2023-01-01') and date('2023-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '5d40fe41-c607-b65b-0866-30298ba9833e') - where pd.id_staff='5c9b540e-6a25-433b-6522-9c6c4f36c9d3' and pd.daydate between date('2023-01-01') and date('2023-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '5c9b540e-6a25-433b-6522-9c6c4f36c9d3' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id from alicehartmann.reportperiod order by startdate,enddate; -QUERYARRAY: select id,startdate,enddate from alicehartmann.reportperiod where -startdate >= date((select min(startdate) from alicehartmann.staffcontract where id_staff='1081bbea-feae-e812-0734-cca5424b0718')) -or date((select min(startdate) from alicehartmann.staffcontract where id_staff='1081bbea-feae-e812-0734-cca5424b0718')) between startdate and enddate order by startdate,enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'1081bbea-feae-e812-0734-cca5424b0718' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='1081bbea-feae-e812-0734-cca5424b0718' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'1081bbea-feae-e812-0734-cca5424b0718' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='1081bbea-feae-e812-0734-cca5424b0718' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='1081bbea-feae-e812-0734-cca5424b0718' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('90632f2f-6134-65d8-bfd0-ab2ece5f7f7f','1081bbea-feae-e812-0734-cca5424b0718') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'1081bbea-feae-e812-0734-cca5424b0718' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='1081bbea-feae-e812-0734-cca5424b0718' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'1081bbea-feae-e812-0734-cca5424b0718' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='1081bbea-feae-e812-0734-cca5424b0718' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='1081bbea-feae-e812-0734-cca5424b0718' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('a0f71278-f95c-bffd-8dd7-d502f0cc88aa','1081bbea-feae-e812-0734-cca5424b0718') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='a565664b-07b7-a90d-be8b-14a585d7766d'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'1081bbea-feae-e812-0734-cca5424b0718' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='1081bbea-feae-e812-0734-cca5424b0718' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'1081bbea-feae-e812-0734-cca5424b0718' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='1081bbea-feae-e812-0734-cca5424b0718' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='1081bbea-feae-e812-0734-cca5424b0718' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('a565664b-07b7-a90d-be8b-14a585d7766d','1081bbea-feae-e812-0734-cca5424b0718') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'1081bbea-feae-e812-0734-cca5424b0718' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='1081bbea-feae-e812-0734-cca5424b0718' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'1081bbea-feae-e812-0734-cca5424b0718' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='1081bbea-feae-e812-0734-cca5424b0718' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='1081bbea-feae-e812-0734-cca5424b0718' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('9a1ca2f0-c1d7-8652-69d9-9dc25057efe8','1081bbea-feae-e812-0734-cca5424b0718') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='5d40fe41-c607-b65b-0866-30298ba9833e'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'1081bbea-feae-e812-0734-cca5424b0718' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='1081bbea-feae-e812-0734-cca5424b0718' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'1081bbea-feae-e812-0734-cca5424b0718' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='1081bbea-feae-e812-0734-cca5424b0718' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='1081bbea-feae-e812-0734-cca5424b0718' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('5d40fe41-c607-b65b-0866-30298ba9833e','1081bbea-feae-e812-0734-cca5424b0718') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select reportperiodunit,reportperiodlength from public.companies where schemata='alicehartmann' -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='1081bbea-feae-e812-0734-cca5424b0718' - ) scx where startdate < enddate and id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-10-11'),date('2021-11-09'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 22 as maxdays,22 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from alicehartmann.staffreportperioddays - where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and daydate between date('2021-09-01') and date('2021-12-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-12-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-12-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from alicehartmann.staffcontract where id_staff='1081bbea-feae-e812-0734-cca5424b0718' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update alicehartmann.staffreportperiod set maxdays=22,contracthours='176:00:00' where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and id_reportperiod='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select * from alicehartmann.reportperiod where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='1081bbea-feae-e812-0734-cca5424b0718' order by rp.startdate,rp.enddate) - sper ) prp where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-09-01') and date('2021-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='1081bbea-feae-e812-0734-cca5424b0718' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='1081bbea-feae-e812-0734-cca5424b0718' and sr.daydate between date('2021-09-01') and date(date_trunc('week',date('2021-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '1081bbea-feae-e812-0734-cca5424b0718' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days') - --where id_staff= '1081bbea-feae-e812-0734-cca5424b0718' and daydate between date('2021-09-01') and date('2021-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=5,last44date=date('2021-11-15'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '90632f2f-6134-65d8-bfd0-ab2ece5f7f7f') - where pd.id_staff='1081bbea-feae-e812-0734-cca5424b0718' and pd.daydate between date('2021-09-01') and date('2021-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1081bbea-feae-e812-0734-cca5424b0718' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='1081bbea-feae-e812-0734-cca5424b0718' - ) scx where startdate < enddate and id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa' order by startdate,enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='1081bbea-feae-e812-0734-cca5424b0718' - ) scx where startdate < enddate and id='a565664b-07b7-a90d-be8b-14a585d7766d' order by startdate,enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='1081bbea-feae-e812-0734-cca5424b0718' - ) scx where startdate < enddate and id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8' order by startdate,enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='1081bbea-feae-e812-0734-cca5424b0718' - ) scx where startdate < enddate and id='5d40fe41-c607-b65b-0866-30298ba9833e' order by startdate,enddate; -EXEC: insert into alicehartmann.staffvacancyyear (id_staff,vacyear) - select id_staff,to_char(daydate,'YYYY')::int4 as vyear from alicehartmann.staffreportperioddays where id_staff='1081bbea-feae-e812-0734-cca5424b0718' group by id_staff,vyear order by id_staff,vyear - on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='2cdf9b30-bbdf-0a25-a736-1c569b116069'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'1081bbea-feae-e812-0734-cca5424b0718' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='1081bbea-feae-e812-0734-cca5424b0718' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'1081bbea-feae-e812-0734-cca5424b0718' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='1081bbea-feae-e812-0734-cca5424b0718' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='1081bbea-feae-e812-0734-cca5424b0718' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='2cdf9b30-bbdf-0a25-a736-1c569b116069'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='1081bbea-feae-e812-0734-cca5424b0718' order by rp.startdate,rp.enddate) - sper ) prp where id='2cdf9b30-bbdf-0a25-a736-1c569b116069'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-01-01') and date('2021-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='1081bbea-feae-e812-0734-cca5424b0718' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='1081bbea-feae-e812-0734-cca5424b0718' and sr.daydate between date('2021-01-01') and date(date_trunc('week',date('2021-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '1081bbea-feae-e812-0734-cca5424b0718' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days') - --where id_staff= '1081bbea-feae-e812-0734-cca5424b0718' and daydate between date('2021-01-01') and date('2021-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '2cdf9b30-bbdf-0a25-a736-1c569b116069') - where pd.id_staff='1081bbea-feae-e812-0734-cca5424b0718' and pd.daydate between date('2021-01-01') and date('2021-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1081bbea-feae-e812-0734-cca5424b0718' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='86c57b67-0f53-6906-da9f-03e90e03afc6'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'1081bbea-feae-e812-0734-cca5424b0718' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='1081bbea-feae-e812-0734-cca5424b0718' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'1081bbea-feae-e812-0734-cca5424b0718' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='1081bbea-feae-e812-0734-cca5424b0718' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='1081bbea-feae-e812-0734-cca5424b0718' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='86c57b67-0f53-6906-da9f-03e90e03afc6'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='1081bbea-feae-e812-0734-cca5424b0718' order by rp.startdate,rp.enddate) - sper ) prp where id='86c57b67-0f53-6906-da9f-03e90e03afc6'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-05-01') and date('2021-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='1081bbea-feae-e812-0734-cca5424b0718' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='1081bbea-feae-e812-0734-cca5424b0718' and sr.daydate between date('2021-05-01') and date(date_trunc('week',date('2021-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '1081bbea-feae-e812-0734-cca5424b0718' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days') - --where id_staff= '1081bbea-feae-e812-0734-cca5424b0718' and daydate between date('2021-05-01') and date('2021-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '86c57b67-0f53-6906-da9f-03e90e03afc6') - where pd.id_staff='1081bbea-feae-e812-0734-cca5424b0718' and pd.daydate between date('2021-05-01') and date('2021-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1081bbea-feae-e812-0734-cca5424b0718' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'1081bbea-feae-e812-0734-cca5424b0718' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='1081bbea-feae-e812-0734-cca5424b0718' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'1081bbea-feae-e812-0734-cca5424b0718' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='1081bbea-feae-e812-0734-cca5424b0718' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='1081bbea-feae-e812-0734-cca5424b0718' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='1081bbea-feae-e812-0734-cca5424b0718' order by rp.startdate,rp.enddate) - sper ) prp where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-09-01') and date('2021-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='1081bbea-feae-e812-0734-cca5424b0718' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='1081bbea-feae-e812-0734-cca5424b0718' and sr.daydate between date('2021-09-01') and date(date_trunc('week',date('2021-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '1081bbea-feae-e812-0734-cca5424b0718' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days') - --where id_staff= '1081bbea-feae-e812-0734-cca5424b0718' and daydate between date('2021-09-01') and date('2021-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=5,last44date=date('2021-11-15'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '90632f2f-6134-65d8-bfd0-ab2ece5f7f7f') - where pd.id_staff='1081bbea-feae-e812-0734-cca5424b0718' and pd.daydate between date('2021-09-01') and date('2021-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1081bbea-feae-e812-0734-cca5424b0718' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'1081bbea-feae-e812-0734-cca5424b0718' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='1081bbea-feae-e812-0734-cca5424b0718' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'1081bbea-feae-e812-0734-cca5424b0718' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='1081bbea-feae-e812-0734-cca5424b0718' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='1081bbea-feae-e812-0734-cca5424b0718' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='1081bbea-feae-e812-0734-cca5424b0718' order by rp.startdate,rp.enddate) - sper ) prp where id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2022-01-01') and date('2022-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='1081bbea-feae-e812-0734-cca5424b0718' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='1081bbea-feae-e812-0734-cca5424b0718' and sr.daydate between date('2022-01-01') and date(date_trunc('week',date('2022-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '1081bbea-feae-e812-0734-cca5424b0718' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-04-30')) + interval '6 days') - --where id_staff= '1081bbea-feae-e812-0734-cca5424b0718' and daydate between date('2022-01-01') and date('2022-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a0f71278-f95c-bffd-8dd7-d502f0cc88aa') - where pd.id_staff='1081bbea-feae-e812-0734-cca5424b0718' and pd.daydate between date('2022-01-01') and date('2022-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1081bbea-feae-e812-0734-cca5424b0718' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='a565664b-07b7-a90d-be8b-14a585d7766d'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'1081bbea-feae-e812-0734-cca5424b0718' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='1081bbea-feae-e812-0734-cca5424b0718' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'1081bbea-feae-e812-0734-cca5424b0718' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='1081bbea-feae-e812-0734-cca5424b0718' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='1081bbea-feae-e812-0734-cca5424b0718' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='a565664b-07b7-a90d-be8b-14a585d7766d'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='1081bbea-feae-e812-0734-cca5424b0718' order by rp.startdate,rp.enddate) - sper ) prp where id='a565664b-07b7-a90d-be8b-14a585d7766d'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and daydate between date(date_trunc('week',date('2022-05-01'))) and date(date_trunc('week',date('2022-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and daydate between date(date_trunc('week',date('2022-05-01'))) and date(date_trunc('week',date('2022-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2022-05-01') and date('2022-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='1081bbea-feae-e812-0734-cca5424b0718' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='1081bbea-feae-e812-0734-cca5424b0718' and sr.daydate between date('2022-05-01') and date(date_trunc('week',date('2022-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '1081bbea-feae-e812-0734-cca5424b0718' and daydate between date(date_trunc('week',date('2022-05-01'))) and date(date_trunc('week',date('2022-08-31')) + interval '6 days') - --where id_staff= '1081bbea-feae-e812-0734-cca5424b0718' and daydate between date('2022-05-01') and date('2022-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a565664b-07b7-a90d-be8b-14a585d7766d') - where pd.id_staff='1081bbea-feae-e812-0734-cca5424b0718' and pd.daydate between date('2022-05-01') and date('2022-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1081bbea-feae-e812-0734-cca5424b0718' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'1081bbea-feae-e812-0734-cca5424b0718' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='1081bbea-feae-e812-0734-cca5424b0718' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'1081bbea-feae-e812-0734-cca5424b0718' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='1081bbea-feae-e812-0734-cca5424b0718' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='1081bbea-feae-e812-0734-cca5424b0718' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='1081bbea-feae-e812-0734-cca5424b0718' order by rp.startdate,rp.enddate) - sper ) prp where id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and daydate between date(date_trunc('week',date('2022-09-01'))) and date(date_trunc('week',date('2022-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and daydate between date(date_trunc('week',date('2022-09-01'))) and date(date_trunc('week',date('2022-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2022-09-01') and date('2022-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='1081bbea-feae-e812-0734-cca5424b0718' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='1081bbea-feae-e812-0734-cca5424b0718' and sr.daydate between date('2022-09-01') and date(date_trunc('week',date('2022-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '1081bbea-feae-e812-0734-cca5424b0718' and daydate between date(date_trunc('week',date('2022-09-01'))) and date(date_trunc('week',date('2022-12-31')) + interval '6 days') - --where id_staff= '1081bbea-feae-e812-0734-cca5424b0718' and daydate between date('2022-09-01') and date('2022-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '9a1ca2f0-c1d7-8652-69d9-9dc25057efe8') - where pd.id_staff='1081bbea-feae-e812-0734-cca5424b0718' and pd.daydate between date('2022-09-01') and date('2022-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1081bbea-feae-e812-0734-cca5424b0718' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='5d40fe41-c607-b65b-0866-30298ba9833e'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'1081bbea-feae-e812-0734-cca5424b0718' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='1081bbea-feae-e812-0734-cca5424b0718' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'1081bbea-feae-e812-0734-cca5424b0718' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='1081bbea-feae-e812-0734-cca5424b0718' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='1081bbea-feae-e812-0734-cca5424b0718' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='5d40fe41-c607-b65b-0866-30298ba9833e'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='1081bbea-feae-e812-0734-cca5424b0718' order by rp.startdate,rp.enddate) - sper ) prp where id='5d40fe41-c607-b65b-0866-30298ba9833e'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and daydate between date(date_trunc('week',date('2023-01-01'))) and date(date_trunc('week',date('2023-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and daydate between date(date_trunc('week',date('2023-01-01'))) and date(date_trunc('week',date('2023-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2023-01-01') and date('2023-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='1081bbea-feae-e812-0734-cca5424b0718' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='1081bbea-feae-e812-0734-cca5424b0718' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2023-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='1081bbea-feae-e812-0734-cca5424b0718' and sr.daydate between date('2023-01-01') and date(date_trunc('week',date('2023-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= '1081bbea-feae-e812-0734-cca5424b0718' and daydate between date(date_trunc('week',date('2023-01-01'))) and date(date_trunc('week',date('2023-04-30')) + interval '6 days') - --where id_staff= '1081bbea-feae-e812-0734-cca5424b0718' and daydate between date('2023-01-01') and date('2023-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '5d40fe41-c607-b65b-0866-30298ba9833e') - where pd.id_staff='1081bbea-feae-e812-0734-cca5424b0718' and pd.daydate between date('2023-01-01') and date('2023-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '1081bbea-feae-e812-0734-cca5424b0718' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id from alicehartmann.reportperiod order by startdate,enddate; -QUERYARRAY: select id,startdate,enddate from alicehartmann.reportperiod where -startdate >= date((select min(startdate) from alicehartmann.staffcontract where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36')) -or date((select min(startdate) from alicehartmann.staffcontract where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36')) between startdate and enddate order by startdate,enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e697a201-a3f0-9c0a-fa90-72aceebfdb36' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e697a201-a3f0-9c0a-fa90-72aceebfdb36' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('90632f2f-6134-65d8-bfd0-ab2ece5f7f7f','e697a201-a3f0-9c0a-fa90-72aceebfdb36') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e697a201-a3f0-9c0a-fa90-72aceebfdb36' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e697a201-a3f0-9c0a-fa90-72aceebfdb36' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('a0f71278-f95c-bffd-8dd7-d502f0cc88aa','e697a201-a3f0-9c0a-fa90-72aceebfdb36') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='a565664b-07b7-a90d-be8b-14a585d7766d'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e697a201-a3f0-9c0a-fa90-72aceebfdb36' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e697a201-a3f0-9c0a-fa90-72aceebfdb36' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('a565664b-07b7-a90d-be8b-14a585d7766d','e697a201-a3f0-9c0a-fa90-72aceebfdb36') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e697a201-a3f0-9c0a-fa90-72aceebfdb36' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e697a201-a3f0-9c0a-fa90-72aceebfdb36' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('9a1ca2f0-c1d7-8652-69d9-9dc25057efe8','e697a201-a3f0-9c0a-fa90-72aceebfdb36') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='5d40fe41-c607-b65b-0866-30298ba9833e'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e697a201-a3f0-9c0a-fa90-72aceebfdb36' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e697a201-a3f0-9c0a-fa90-72aceebfdb36' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' group by rp.id); -EXEC: INSERT INTO alicehartmann.staffreportperiod (id_reportperiod, id_staff) - VALUES ('5d40fe41-c607-b65b-0866-30298ba9833e','e697a201-a3f0-9c0a-fa90-72aceebfdb36') on conflict on constraint uniq_staffreportperiod_cal do nothing; -QUERY: select reportperiodunit,reportperiodlength from public.companies where schemata='alicehartmann' -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' - ) scx where startdate < enddate and id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f' order by startdate,enddate; -QUERY: select sum(dow) as maxdays from ( select case when date_part('isodow',generate_series) in (6,7) then 0 else 1 end as dow from pg_catalog.generate_series(date('2021-10-11'),date('2021-11-09'),'1 day')) mxdays -QUERY: select sum(maxdays) as maxdays,sum(contracthours - ('00:00:'|| extract(second from contracthours))::interval ) as itmcontracthours from ( - select 22 as maxdays,22 * (round(cast(((extract(epoch from (current_date + weekhours::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0) /weekdays as numeric) ,2)+0.00) * '01:00:00'::interval as contracthours from ( - select case when count(daydate) >= weekdays then weekdays else weekdays-count(daydate)-1 end as maxdays, calweek,count(daydate) as cntdays,count(sundays) as sundays,weekdays,weekhours from ( - - select id_staff,date(date_trunc('week',daydate)) as calweek,daydate,case when date_part('isodow',daydate)::int4=7 then 1 else null end as sundays - from alicehartmann.staffreportperioddays - where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and daydate between date('2021-09-01') and date('2021-12-31') - ) wgr - left join ( - select date(date_trunc('week',startdate)) as weekstartdate,startdate,case when enddate is null then date('2021-12-31') else enddate end as enddate,case when enddate is null then date(date_trunc('week',date('2021-12-31')) + interval '6 days') else enddate end as weekenddate,weekdays,weekhours from alicehartmann.staffcontract where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' - ) sc on (wgr.calweek between sc.weekstartdate and sc.weekenddate ) where wgr.daydate between sc.startdate and sc.enddate group by sc.weekhours,sc.weekdays,calweek - ) rnddays group by weekhours,weekdays) xx -EXEC: update alicehartmann.staffreportperiod set maxdays=22,contracthours='176:00:00' where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and id_reportperiod='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select * from alicehartmann.reportperiod where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' order by rp.startdate,rp.enddate) - sper ) prp where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-09-01') and date('2021-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and sr.daydate between date('2021-09-01') and date(date_trunc('week',date('2021-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= 'e697a201-a3f0-9c0a-fa90-72aceebfdb36' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days') - --where id_staff= 'e697a201-a3f0-9c0a-fa90-72aceebfdb36' and daydate between date('2021-09-01') and date('2021-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=5,last44date=date('2021-11-15'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '90632f2f-6134-65d8-bfd0-ab2ece5f7f7f') - where pd.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and pd.daydate between date('2021-09-01') and date('2021-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'e697a201-a3f0-9c0a-fa90-72aceebfdb36' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' - ) scx where startdate < enddate and id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa' order by startdate,enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' - ) scx where startdate < enddate and id='a565664b-07b7-a90d-be8b-14a585d7766d' order by startdate,enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' - ) scx where startdate < enddate and id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8' order by startdate,enddate; -QUERYARRAY: select id,weekhours,weekdays,startdate,enddate,defaultfreedays from ( - select rp.id,case when sc.startdate < rp.startdate then rp.startdate else sc.startdate end as startdate , - case when sc.enddate is null or sc.enddate > rp.enddate then rp.enddate else sc.enddate end as enddate, - sc.weekhours,sc.weekdays,sc.defaultfreedays from alicehartmann.staffcontract sc - cross join alicehartmann.reportperiod rp - where sc.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' - ) scx where startdate < enddate and id='5d40fe41-c607-b65b-0866-30298ba9833e' order by startdate,enddate; -EXEC: insert into alicehartmann.staffvacancyyear (id_staff,vacyear) - select id_staff,to_char(daydate,'YYYY')::int4 as vyear from alicehartmann.staffreportperioddays where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' group by id_staff,vyear order by id_staff,vyear - on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='2cdf9b30-bbdf-0a25-a736-1c569b116069'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e697a201-a3f0-9c0a-fa90-72aceebfdb36' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e697a201-a3f0-9c0a-fa90-72aceebfdb36' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='2cdf9b30-bbdf-0a25-a736-1c569b116069'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' order by rp.startdate,rp.enddate) - sper ) prp where id='2cdf9b30-bbdf-0a25-a736-1c569b116069'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-01-01') and date('2021-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and sr.daydate between date('2021-01-01') and date(date_trunc('week',date('2021-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= 'e697a201-a3f0-9c0a-fa90-72aceebfdb36' and daydate between date(date_trunc('week',date('2021-01-01'))) and date(date_trunc('week',date('2021-04-30')) + interval '6 days') - --where id_staff= 'e697a201-a3f0-9c0a-fa90-72aceebfdb36' and daydate between date('2021-01-01') and date('2021-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '2cdf9b30-bbdf-0a25-a736-1c569b116069') - where pd.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and pd.daydate between date('2021-01-01') and date('2021-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'e697a201-a3f0-9c0a-fa90-72aceebfdb36' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='86c57b67-0f53-6906-da9f-03e90e03afc6'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e697a201-a3f0-9c0a-fa90-72aceebfdb36' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e697a201-a3f0-9c0a-fa90-72aceebfdb36' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='86c57b67-0f53-6906-da9f-03e90e03afc6'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' order by rp.startdate,rp.enddate) - sper ) prp where id='86c57b67-0f53-6906-da9f-03e90e03afc6'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-05-01') and date('2021-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and sr.daydate between date('2021-05-01') and date(date_trunc('week',date('2021-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= 'e697a201-a3f0-9c0a-fa90-72aceebfdb36' and daydate between date(date_trunc('week',date('2021-05-01'))) and date(date_trunc('week',date('2021-08-31')) + interval '6 days') - --where id_staff= 'e697a201-a3f0-9c0a-fa90-72aceebfdb36' and daydate between date('2021-05-01') and date('2021-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '86c57b67-0f53-6906-da9f-03e90e03afc6') - where pd.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and pd.daydate between date('2021-05-01') and date('2021-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'e697a201-a3f0-9c0a-fa90-72aceebfdb36' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e697a201-a3f0-9c0a-fa90-72aceebfdb36' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e697a201-a3f0-9c0a-fa90-72aceebfdb36' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' order by rp.startdate,rp.enddate) - sper ) prp where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2021-09-01') and date('2021-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2021-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and sr.daydate between date('2021-09-01') and date(date_trunc('week',date('2021-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= 'e697a201-a3f0-9c0a-fa90-72aceebfdb36' and daydate between date(date_trunc('week',date('2021-09-01'))) and date(date_trunc('week',date('2021-12-31')) + interval '6 days') - --where id_staff= 'e697a201-a3f0-9c0a-fa90-72aceebfdb36' and daydate between date('2021-09-01') and date('2021-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=5,last44date=date('2021-11-15'),avgtotalweekhours=null,hoursdiff=csp.diffhours - FROM ( - select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '90632f2f-6134-65d8-bfd0-ab2ece5f7f7f') - where pd.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and pd.daydate between date('2021-09-01') and date('2021-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'e697a201-a3f0-9c0a-fa90-72aceebfdb36' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e697a201-a3f0-9c0a-fa90-72aceebfdb36' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e697a201-a3f0-9c0a-fa90-72aceebfdb36' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' order by rp.startdate,rp.enddate) - sper ) prp where id='a0f71278-f95c-bffd-8dd7-d502f0cc88aa'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2022-01-01') and date('2022-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and sr.daydate between date('2022-01-01') and date(date_trunc('week',date('2022-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= 'e697a201-a3f0-9c0a-fa90-72aceebfdb36' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-04-30')) + interval '6 days') - --where id_staff= 'e697a201-a3f0-9c0a-fa90-72aceebfdb36' and daydate between date('2022-01-01') and date('2022-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a0f71278-f95c-bffd-8dd7-d502f0cc88aa') - where pd.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and pd.daydate between date('2022-01-01') and date('2022-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'e697a201-a3f0-9c0a-fa90-72aceebfdb36' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='a565664b-07b7-a90d-be8b-14a585d7766d'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e697a201-a3f0-9c0a-fa90-72aceebfdb36' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e697a201-a3f0-9c0a-fa90-72aceebfdb36' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='a565664b-07b7-a90d-be8b-14a585d7766d'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' order by rp.startdate,rp.enddate) - sper ) prp where id='a565664b-07b7-a90d-be8b-14a585d7766d'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and daydate between date(date_trunc('week',date('2022-05-01'))) and date(date_trunc('week',date('2022-08-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and daydate between date(date_trunc('week',date('2022-05-01'))) and date(date_trunc('week',date('2022-08-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2022-05-01') and date('2022-08-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-05-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and sr.daydate between date('2022-05-01') and date(date_trunc('week',date('2022-08-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= 'e697a201-a3f0-9c0a-fa90-72aceebfdb36' and daydate between date(date_trunc('week',date('2022-05-01'))) and date(date_trunc('week',date('2022-08-31')) + interval '6 days') - --where id_staff= 'e697a201-a3f0-9c0a-fa90-72aceebfdb36' and daydate between date('2022-05-01') and date('2022-08-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a565664b-07b7-a90d-be8b-14a585d7766d') - where pd.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and pd.daydate between date('2022-05-01') and date('2022-08-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'e697a201-a3f0-9c0a-fa90-72aceebfdb36' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e697a201-a3f0-9c0a-fa90-72aceebfdb36' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e697a201-a3f0-9c0a-fa90-72aceebfdb36' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' order by rp.startdate,rp.enddate) - sper ) prp where id='9a1ca2f0-c1d7-8652-69d9-9dc25057efe8'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and daydate between date(date_trunc('week',date('2022-09-01'))) and date(date_trunc('week',date('2022-12-31')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and daydate between date(date_trunc('week',date('2022-09-01'))) and date(date_trunc('week',date('2022-12-31')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2022-09-01') and date('2022-12-31') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2022-09-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and sr.daydate between date('2022-09-01') and date(date_trunc('week',date('2022-12-31')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= 'e697a201-a3f0-9c0a-fa90-72aceebfdb36' and daydate between date(date_trunc('week',date('2022-09-01'))) and date(date_trunc('week',date('2022-12-31')) + interval '6 days') - --where id_staff= 'e697a201-a3f0-9c0a-fa90-72aceebfdb36' and daydate between date('2022-09-01') and date('2022-12-31') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '9a1ca2f0-c1d7-8652-69d9-9dc25057efe8') - where pd.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and pd.daydate between date('2022-09-01') and date('2022-12-31') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'e697a201-a3f0-9c0a-fa90-72aceebfdb36' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='5d40fe41-c607-b65b-0866-30298ba9833e'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'e697a201-a3f0-9c0a-fa90-72aceebfdb36' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-10-11'))) as firstday , date(date_trunc('week',date('2021-11-09')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -EXEC: insert into alicehartmann.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) -SELECT date_trunc('day', dd)::date as daydate,'e697a201-a3f0-9c0a-fa90-72aceebfdb36' as id_staff, null as payedpause, - '08:00:00' as wdcontracthours -FROM generate_series( '2021-10-11'::timestamp,'2021-11-14'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday -do update set wdcontracthours = '08:00:00'; -EXEC: DELETE FROM alicehartmann.staffreportperioddays where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and (daydate > date('2021-11-14') or daydate < date('2021-10-11')) - OR (id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' AND daydate not between date('2021-10-11') and date('2021-11-14')); -EXEC: delete from alicehartmann.staffreportperiod sp where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and id_reportperiod not in ( -select rp.id from alicehartmann.reportperiod rp left join alicehartmann.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) -where pd.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' group by rp.id); -QUERY: select * from alicehartmann.reportperiod where id='5d40fe41-c607-b65b-0866-30298ba9833e'; -QUERY: select coalesce(prevperiod,'') as prevperiod from (select lag(id_reportperiod,1) over (order by startdate,enddate) as prevperiod,id from ( - select srp.id_reportperiod ,startdate,enddate,rp.id from alicehartmann.staffreportperiod srp - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - where srp.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' order by rp.startdate,rp.enddate) - sper ) prp where id='5d40fe41-c607-b65b-0866-30298ba9833e'; -EXEC: update alicehartmann.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 + ds.partunemplhours::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)-(preds.pdt1+preds.pdt2) as worktime, - (preds.pdt1+preds.pdt2) as timepause, - wdcontracthours - from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours,nighthours, - case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1::interval - timestart1::interval else timeend1::interval - timestart1::interval 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::interval - timestart2::interval else timeend2::interval - timestart2::interval 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::interval - pausestart1::interval else pauseend1::interval - pausestart1::interval 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::interval - pausestart2::interval else pauseend2::interval - pausestart2::interval 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::interval - timeend1::interval - else null end as interruption, - wdcontracthours - from alicehartmann.staffreportperioddays where id in (select id from alicehartmann.staffreportperioddays where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and daydate between date(date_trunc('week',date('2023-01-01'))) and date(date_trunc('week',date('2023-04-30')) + interval '6 days')) - ) preds) ds where spds.id=ds.id; -EXEC: update alicehartmann.staffreportperioddays spds set - nighthours=nh from ( - select id,daydate,timestart1,timeend1, timestart2,timeend2, - coalesce((case when timeend1 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend1::interval end) - - (case when timestart1 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart1::interval end),'00:00:00'::interval) - + coalesce((case when timeend2 not between '01:00:01'::interval and '05:59:59'::interval then '06:00:00'::interval else timeend2::interval end) - - (case when timestart2 not between '01:00:01'::interval and '05:59:59'::interval then '01:00:00'::interval else timestart2::interval end),'00:00:00'::interval) as nh - from alicehartmann.staffreportperioddays s where - (timeend1 between '01:00:01' and '05:59:59' or timeend2 between '01:00:01' and '05:59:59' - or timestart1 between '01:00:01' and '05:59:59' or timestart2 between '01:00:01' and '05:59:59') - and id in (select id from alicehartmann.staffreportperioddays where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and daydate between date(date_trunc('week',date('2023-01-01'))) and date(date_trunc('week',date('2023-04-30')) + interval '6 days')) - ) ds - where spds.id=ds.id; -QUERY: select max(rowx) as statussuncount, sum(modx) as suppvacancysunwork from ( -select daydate,rowx, case when mod(rowx,20) = 0 then 2 else null end as modx from ( -select daydate,+row_number() over (order by daydate) as rowx from alicehartmann.staffreportperioddays -where daydate between date('2023-01-01') and date('2023-04-30') -and date_part('isodow',daydate)::int4 = 7 and workhours > '00:00:00'::time -and id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' order by daydate -) xsunday) sunresult; -QUERY: select sum(suppvacancy44hours) as curvac44h from alicehartmann.staffreportperiod where id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and id_reportperiod in (select id from alicehartmann.reportperiod where date_part('year',startdate)::int4=date_part('year',date('2023-01-01'))); -QUERY: select *,case when week44s >= 8 then (week44s/8)::int else null end as plusdays from ( -select date(date_trunc('week',max(maxdate)) + interval '7 days') as maxdate,max(sumx) as week44s,mod(max(sumx),8) as weeksrest from ( -select weekstart,sum(case when sum(cnt44) > 0 then 0 else 1 end) over (order by weekstart) as sumx, max(daydate) as maxdate from ( - SELECT date(date_trunc('week',yy.daydate)) as weekstart,daydate, - case when (date_part('epoch', yy.daydate + yy.timestart - (yy.ndaydate + yy.ntimeend)) * '00:00:01'::interval) >= '44:00:00'::interval then 1 else 0 end as cnt44 - FROM ( SELECT lag(xx_1.daydate, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ndaydate, - lag(xx_1.timeend, 1) OVER (ORDER BY xx_1.id_staff, xx_1.daydate) AS ntimeend, - xx_1.id_staff, xx_1.daydate, xx_1.timestart, xx_1.timeend - FROM ( SELECT sr.id_staff, sr.daydate, - CASE WHEN sr.timestart1 IS NOT NULL THEN sr.timestart1 ELSE sr.timestart2 END AS timestart, - CASE WHEN sr.timestart2 IS NOT NULL THEN sr.timeend2 ELSE sr.timeend1 END AS timeend - FROM alicehartmann.staffreportperioddays sr - WHERE sr.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and sr.daydate between date('2023-01-01') and date(date_trunc('week',date('2023-04-30')) - interval '1 day') - and sr.dayhours IS NOT NULL AND sr.dayhours <> '00:00:00'::time without time zone - ORDER BY sr.id_staff, sr.daydate) xx_1) yy order by yy.daydate,weekstart - ) aa group by aa.weekstart order by weekstart - ) bb)cc; -QUERY: select weekstart,id_staff,avgtotalhours from ( - select ws.weekstart, ws.id_staff, - AVG(ws.totalhours) over (order by ws.weekstart) as avgtotalhours - from ( - SELECT weekstart, id_staff, -sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours::interval END) AS totalhours - FROM (select *,date(date_trunc('week', daydate)) AS weekstart, - date(date_trunc('week', daydate) + interval '6 days') AS weekend, - date_part('week', daydate) AS calweek, - date_part('isoyear', daydate) AS calyear from alicehartmann.staffreportperioddays - where id_staff= 'e697a201-a3f0-9c0a-fa90-72aceebfdb36' and daydate between date(date_trunc('week',date('2023-01-01'))) and date(date_trunc('week',date('2023-04-30')) + interval '6 days') - --where id_staff= 'e697a201-a3f0-9c0a-fa90-72aceebfdb36' and daydate between date('2023-01-01') and date('2023-04-30') - ) srpd GROUP BY srpd.weekstart,srpd.id_staff - ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1; -EXEC: update alicehartmann.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, - nighthours=csp.nighthours, - 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 as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours,nighthours from ( - select dp.id, - sum(pd.workhours) as workhours, - sum(pd.dayhours) as totalhours, - sum(coalesce(pd.nighthours,'00:00:00'::interval)) as nighthours, - 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 alicehartmann.staffreportperioddays pd - join alicehartmann.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '5d40fe41-c607-b65b-0866-30298ba9833e') - where pd.id_staff='e697a201-a3f0-9c0a-fa90-72aceebfdb36' and pd.daydate between date('2023-01-01') and date('2023-04-30') - group by dp.id,dp.payedhours,dp.transferedhourscalc - ) rp) csp where csp.id=rpd.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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'e697a201-a3f0-9c0a-fa90-72aceebfdb36' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id from alicehartmann.reportperiod order by startdate,enddate; -QUERYARRAY: select id,startdate,enddate from alicehartmann.reportperiod where -startdate >= date((select min(startdate) from alicehartmann.staffcontract where id_staff='38a1b05d-5d02-3d2b-e6bb-8105b1a7eabe')) -or date((select min(startdate) from alicehartmann.staffcontract where id_staff='38a1b05d-5d02-3d2b-e6bb-8105b1a7eabe')) between startdate and enddate order by startdate,enddate; -QUERY: select date(date_trunc('week',min(startdate))) as startdatealt,min(startdate) as startdate,max(enddate) as enddate from alicehartmann.reportperiod where id='90632f2f-6134-65d8-bfd0-ab2ece5f7f7f'; -QUERY: select payedpauses,reportperiodunit from public.companies where schemata ='alicehartmann' -QUERYARRAY: select case when sc.startdate > rp.minstartdate then sc.startdate else rp.minstartdatealt end as startdate , -case when sc.enddate is null or sc.enddate > rp.maxenddate then rp.maxenddate else sc.enddate end as enddate, -sc.startdate as scstart,sc.enddate as scend,rp.minstartdate as minperiodstart,rp.maxenddate as maxperiodend, -sc.weekhours,sc.weekdays from alicehartmann.staffcontract sc -left join (select date(date_trunc('week',min(startdate))) as minstartdatealt,min(startdate) as minstartdate,max(enddate) as maxenddate,'38a1b05d-5d02-3d2b-e6bb-8105b1a7eabe' as id_staff from alicehartmann.reportperiod) rp on rp.id_staff=sc.id_staff -where sc.id_staff='38a1b05d-5d02-3d2b-e6bb-8105b1a7eabe' order by startdate,enddate; -QUERY: select date(date_trunc('week',date('2021-09-27'))) as firstday , date(date_trunc('week',date('2021-10-31')) + interval '6 days') as lastday -QUERY: select round(cast(((extract(epoch from (current_date + '40:00:00'::interval)::timestamp) - extract(epoch from current_date::timestamp))/3600.0)/5 as numeric) ,2) * '01:00:00'::interval as wdcontracthours -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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 alicehartmann.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 alicehartmann.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = '86c57b67-0f53-6906-da9f-03e90e03afc6' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = '90632f2f-6134-65d8-bfd0-ab2ece5f7f7f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = 'a0f71278-f95c-bffd-8dd7-d502f0cc88aa' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = '9a1ca2f0-c1d7-8652-69d9-9dc25057efe8' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = '5d40fe41-c607-b65b-0866-30298ba9833e' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = '9a1ca2f0-c1d7-8652-69d9-9dc25057efe8' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = 'a565664b-07b7-a90d-be8b-14a585d7766d' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = 'a0f71278-f95c-bffd-8dd7-d502f0cc88aa' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = '90632f2f-6134-65d8-bfd0-ab2ece5f7f7f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = '86c57b67-0f53-6906-da9f-03e90e03afc6' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = '2cdf9b30-bbdf-0a25-a736-1c569b116069' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = '86c57b67-0f53-6906-da9f-03e90e03afc6' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = '90632f2f-6134-65d8-bfd0-ab2ece5f7f7f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = 'a0f71278-f95c-bffd-8dd7-d502f0cc88aa' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = '2cdf9b30-bbdf-0a25-a736-1c569b116069' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: 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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate, - coalesce(to_char(spd.vacancyhours::interval,'HH24:MI'),'') as vacancyhours, - coalesce(to_char(spd.vacillhours::interval,'HH24:MI'),'') as vacillhours, - coalesce(to_char(spd.vacextrahours::interval,'HH24:MI'),'') as vacextrahours, - coalesce ( spd.vacancycomment || ' ' ,'') || coalesce( spd.vacillcomment || ' ' ,'') || coalesce( spd.vacextracomment|| ' ','') as description - from alicehartmann.staffreportperioddays spd - join alicehartmann.staff st on (st.id=spd.id_staff) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and date_trunc('month',spd.daydate)=date_trunc('month',date('2022-01-01')) order by st.surname,st.prename,spd.daydate -QUERYARRAY: select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate, - coalesce(to_char(spd.vacancyhours::interval,'HH24:MI'),'') as vacancyhours, - coalesce(to_char(spd.vacillhours::interval,'HH24:MI'),'') as vacillhours, - coalesce(to_char(spd.vacextrahours::interval,'HH24:MI'),'') as vacextrahours, - coalesce ( spd.vacancycomment || ' ' ,'') || coalesce( spd.vacillcomment || ' ' ,'') || coalesce( spd.vacextracomment|| ' ','') as description - from alicehartmann.staffreportperioddays spd - join alicehartmann.staff st on (st.id=spd.id_staff) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and date_trunc('month',spd.daydate)=date_trunc('month',date('2022-01-01')) order by st.surname,st.prename,spd.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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.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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate, - coalesce(to_char(spd.vacancyhours::interval,'HH24:MI'),'') as vacancyhours, - coalesce(to_char(spd.vacillhours::interval,'HH24:MI'),'') as vacillhours, - coalesce(to_char(spd.vacextrahours::interval,'HH24:MI'),'') as vacextrahours, - coalesce ( spd.vacancycomment || ' ' ,'') || coalesce( spd.vacillcomment || ' ' ,'') || coalesce( spd.vacextracomment|| ' ','') as description - from alicehartmann.staffreportperioddays spd - join alicehartmann.staff st on (st.id=spd.id_staff) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and date_trunc('month',spd.daydate)=date_trunc('month',date('2022-01-01')) order by st.surname,st.prename,spd.daydate -QUERYARRAY: select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate, - coalesce(to_char(spd.vacancyhours::interval,'HH24:MI'),'') as vacancyhours, - coalesce(to_char(spd.vacillhours::interval,'HH24:MI'),'') as vacillhours, - coalesce(to_char(spd.vacextrahours::interval,'HH24:MI'),'') as vacextrahours, - coalesce ( spd.vacancycomment || ' ' ,'') || coalesce( spd.vacillcomment || ' ' ,'') || coalesce( spd.vacextracomment|| ' ','') as description - from alicehartmann.staffreportperioddays spd - join alicehartmann.staff st on (st.id=spd.id_staff) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and date_trunc('month',spd.daydate)=date_trunc('month',date('2022-01-01')) order by st.surname,st.prename,spd.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: 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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from alicehartmann.staffreportperioddays spd - join alicehartmann.staff st on (st.id=spd.id_staff) - join alicehartmann.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and date_trunc('year',spd.daydate)=date_trunc('year',date('2022-01-01')) - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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.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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' 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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from alicehartmann.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='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; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from alicehartmann.staff where id='f58b0cce-2466-1b6c-befc-033cc2d0422a' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from alicehartmann.staffcontract where id_staff='f58b0cce-2466-1b6c-befc-033cc2d0422a' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from alicehartmann.staffvacancyyear where id_staff='f58b0cce-2466-1b6c-befc-033cc2d0422a' order by vacyear; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from alicehartmann.staffreportperioddays spd - join alicehartmann.staff st on (st.id=spd.id_staff) - join alicehartmann.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='f58b0cce-2466-1b6c-befc-033cc2d0422a' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from alicehartmann.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from alicehartmann.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join alicehartmann.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - join alicehartmann.staff st on (pd.id_staff=st.id) - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f58b0cce-2466-1b6c-befc-033cc2d0422a' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f58b0cce-2466-1b6c-befc-033cc2d0422a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from alicehartmann.staff where id='6f8036b4-338f-a581-2256-4e8c59646836' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from alicehartmann.staffcontract where id_staff='6f8036b4-338f-a581-2256-4e8c59646836' order by startdate,enddate; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '6f8036b4-338f-a581-2256-4e8c59646836' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from alicehartmann.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from alicehartmann.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join alicehartmann.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - join alicehartmann.staff st on (pd.id_staff=st.id) - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '6f8036b4-338f-a581-2256-4e8c59646836' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from alicehartmann.staffreportperioddays spd - join alicehartmann.staff st on (st.id=spd.id_staff) - join alicehartmann.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='6f8036b4-338f-a581-2256-4e8c59646836' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from alicehartmann.staffvacancyyear where id_staff='6f8036b4-338f-a581-2256-4e8c59646836' order by vacyear; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from alicehartmann.staff where id='5fc17f70-b15b-41d4-105c-de0791994a49' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from alicehartmann.staffcontract where id_staff='5fc17f70-b15b-41d4-105c-de0791994a49' order by startdate,enddate; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '5fc17f70-b15b-41d4-105c-de0791994a49' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from alicehartmann.staffreportperioddays spd - join alicehartmann.staff st on (st.id=spd.id_staff) - join alicehartmann.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='5fc17f70-b15b-41d4-105c-de0791994a49' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from alicehartmann.staffvacancyyear where id_staff='5fc17f70-b15b-41d4-105c-de0791994a49' order by vacyear; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from alicehartmann.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from alicehartmann.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join alicehartmann.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - join alicehartmann.staff st on (pd.id_staff=st.id) - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '5fc17f70-b15b-41d4-105c-de0791994a49' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from alicehartmann.staff where id='d30df0ed-8f9b-61c5-17a2-e753bb44a3ad' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'd30df0ed-8f9b-61c5-17a2-e753bb44a3ad' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from alicehartmann.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from alicehartmann.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join alicehartmann.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - join alicehartmann.staff st on (pd.id_staff=st.id) - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'd30df0ed-8f9b-61c5-17a2-e753bb44a3ad' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from alicehartmann.staffvacancyyear where id_staff='d30df0ed-8f9b-61c5-17a2-e753bb44a3ad' 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 alicehartmann.staffcontract where id_staff='d30df0ed-8f9b-61c5-17a2-e753bb44a3ad' order by startdate,enddate; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from alicehartmann.staffreportperioddays spd - join alicehartmann.staff st on (st.id=spd.id_staff) - join alicehartmann.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='d30df0ed-8f9b-61c5-17a2-e753bb44a3ad' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from alicehartmann.staff where id='94d46d03-6d50-ecba-418e-8e5b9ef707c3' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from alicehartmann.staffvacancyyear where id_staff='94d46d03-6d50-ecba-418e-8e5b9ef707c3' order by vacyear; -(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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '94d46d03-6d50-ecba-418e-8e5b9ef707c3' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from alicehartmann.staffcontract where id_staff='94d46d03-6d50-ecba-418e-8e5b9ef707c3' order by startdate,enddate; -e, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from alicehartmann.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from alicehartmann.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join alicehartmann.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - join alicehartmann.staff st on (pd.id_staff=st.id) - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '94d46d03-6d50-ecba-418e-8e5b9ef707c3' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from alicehartmann.staffreportperioddays spd - join alicehartmann.staff st on (st.id=spd.id_staff) - join alicehartmann.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='94d46d03-6d50-ecba-418e-8e5b9ef707c3' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from alicehartmann.staff where id='d5e3ca73-bae5-79b5-9554-40617a726128' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'd5e3ca73-bae5-79b5-9554-40617a726128' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from alicehartmann.staffcontract where id_staff='d5e3ca73-bae5-79b5-9554-40617a726128' order by startdate,enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from alicehartmann.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from alicehartmann.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join alicehartmann.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - join alicehartmann.staff st on (pd.id_staff=st.id) - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'd5e3ca73-bae5-79b5-9554-40617a726128' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from alicehartmann.staffreportperioddays spd - join alicehartmann.staff st on (st.id=spd.id_staff) - join alicehartmann.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='d5e3ca73-bae5-79b5-9554-40617a726128' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from alicehartmann.staffvacancyyear where id_staff='d5e3ca73-bae5-79b5-9554-40617a726128' order by vacyear; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from alicehartmann.staff where id='52ab3ff9-7d74-abcd-01fa-6d6860e1bbea' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from alicehartmann.staffcontract where id_staff='52ab3ff9-7d74-abcd-01fa-6d6860e1bbea' order by startdate,enddate; -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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '52ab3ff9-7d74-abcd-01fa-6d6860e1bbea' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from alicehartmann.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from alicehartmann.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join alicehartmann.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - join alicehartmann.staff st on (pd.id_staff=st.id) - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = '52ab3ff9-7d74-abcd-01fa-6d6860e1bbea' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from alicehartmann.staffreportperioddays spd - join alicehartmann.staff st on (st.id=spd.id_staff) - join alicehartmann.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='52ab3ff9-7d74-abcd-01fa-6d6860e1bbea' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from alicehartmann.staffvacancyyear where id_staff='52ab3ff9-7d74-abcd-01fa-6d6860e1bbea' order by vacyear; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from alicehartmann.staff where id='f58b0cce-2466-1b6c-befc-033cc2d0422a' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f58b0cce-2466-1b6c-befc-033cc2d0422a' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from alicehartmann.staffcontract where id_staff='f58b0cce-2466-1b6c-befc-033cc2d0422a' order by startdate,enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from alicehartmann.staffvacancyyear where id_staff='f58b0cce-2466-1b6c-befc-033cc2d0422a' order by vacyear; -QUERYARRAY: select id_staff || '_' || mmonth || '_' || myear as id,surname || ' ' || prename as staffname ,id_staff,groupname, - -- vacancyhours,vacillhours,vacextrahours,vacancycomment,vacillcomment,vacextracomment,mday,daydate,vactotal, - mmonth,myear, case when regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='01' then vcomment else null end,','),',,',',','g') end as c01,string_agg(case when mday='01' then vtypes else null end,'') as t01,to_char(sum(case when mday='01' then vactotal else null end),'HH24:MI') as d01,case when regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='02' then vcomment else null end,','),',,',',','g') end as c02,string_agg(case when mday='02' then vtypes else null end,'') as t02,to_char(sum(case when mday='02' then vactotal else null end),'HH24:MI') as d02,case when regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='03' then vcomment else null end,','),',,',',','g') end as c03,string_agg(case when mday='03' then vtypes else null end,'') as t03,to_char(sum(case when mday='03' then vactotal else null end),'HH24:MI') as d03,case when regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='04' then vcomment else null end,','),',,',',','g') end as c04,string_agg(case when mday='04' then vtypes else null end,'') as t04,to_char(sum(case when mday='04' then vactotal else null end),'HH24:MI') as d04,case when regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='05' then vcomment else null end,','),',,',',','g') end as c05,string_agg(case when mday='05' then vtypes else null end,'') as t05,to_char(sum(case when mday='05' then vactotal else null end),'HH24:MI') as d05,case when regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='06' then vcomment else null end,','),',,',',','g') end as c06,string_agg(case when mday='06' then vtypes else null end,'') as t06,to_char(sum(case when mday='06' then vactotal else null end),'HH24:MI') as d06,case when regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='07' then vcomment else null end,','),',,',',','g') end as c07,string_agg(case when mday='07' then vtypes else null end,'') as t07,to_char(sum(case when mday='07' then vactotal else null end),'HH24:MI') as d07,case when regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='08' then vcomment else null end,','),',,',',','g') end as c08,string_agg(case when mday='08' then vtypes else null end,'') as t08,to_char(sum(case when mday='08' then vactotal else null end),'HH24:MI') as d08,case when regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='09' then vcomment else null end,','),',,',',','g') end as c09,string_agg(case when mday='09' then vtypes else null end,'') as t09,to_char(sum(case when mday='09' then vactotal else null end),'HH24:MI') as d09,case when regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='10' then vcomment else null end,','),',,',',','g') end as c10,string_agg(case when mday='10' then vtypes else null end,'') as t10,to_char(sum(case when mday='10' then vactotal else null end),'HH24:MI') as d10,case when regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='11' then vcomment else null end,','),',,',',','g') end as c11,string_agg(case when mday='11' then vtypes else null end,'') as t11,to_char(sum(case when mday='11' then vactotal else null end),'HH24:MI') as d11,case when regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='12' then vcomment else null end,','),',,',',','g') end as c12,string_agg(case when mday='12' then vtypes else null end,'') as t12,to_char(sum(case when mday='12' then vactotal else null end),'HH24:MI') as d12,case when regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='13' then vcomment else null end,','),',,',',','g') end as c13,string_agg(case when mday='13' then vtypes else null end,'') as t13,to_char(sum(case when mday='13' then vactotal else null end),'HH24:MI') as d13,case when regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='14' then vcomment else null end,','),',,',',','g') end as c14,string_agg(case when mday='14' then vtypes else null end,'') as t14,to_char(sum(case when mday='14' then vactotal else null end),'HH24:MI') as d14,case when regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='15' then vcomment else null end,','),',,',',','g') end as c15,string_agg(case when mday='15' then vtypes else null end,'') as t15,to_char(sum(case when mday='15' then vactotal else null end),'HH24:MI') as d15,case when regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='16' then vcomment else null end,','),',,',',','g') end as c16,string_agg(case when mday='16' then vtypes else null end,'') as t16,to_char(sum(case when mday='16' then vactotal else null end),'HH24:MI') as d16,case when regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='17' then vcomment else null end,','),',,',',','g') end as c17,string_agg(case when mday='17' then vtypes else null end,'') as t17,to_char(sum(case when mday='17' then vactotal else null end),'HH24:MI') as d17,case when regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='18' then vcomment else null end,','),',,',',','g') end as c18,string_agg(case when mday='18' then vtypes else null end,'') as t18,to_char(sum(case when mday='18' then vactotal else null end),'HH24:MI') as d18,case when regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='19' then vcomment else null end,','),',,',',','g') end as c19,string_agg(case when mday='19' then vtypes else null end,'') as t19,to_char(sum(case when mday='19' then vactotal else null end),'HH24:MI') as d19,case when regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='20' then vcomment else null end,','),',,',',','g') end as c20,string_agg(case when mday='20' then vtypes else null end,'') as t20,to_char(sum(case when mday='20' then vactotal else null end),'HH24:MI') as d20,case when regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='21' then vcomment else null end,','),',,',',','g') end as c21,string_agg(case when mday='21' then vtypes else null end,'') as t21,to_char(sum(case when mday='21' then vactotal else null end),'HH24:MI') as d21,case when regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='22' then vcomment else null end,','),',,',',','g') end as c22,string_agg(case when mday='22' then vtypes else null end,'') as t22,to_char(sum(case when mday='22' then vactotal else null end),'HH24:MI') as d22,case when regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='23' then vcomment else null end,','),',,',',','g') end as c23,string_agg(case when mday='23' then vtypes else null end,'') as t23,to_char(sum(case when mday='23' then vactotal else null end),'HH24:MI') as d23,case when regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='24' then vcomment else null end,','),',,',',','g') end as c24,string_agg(case when mday='24' then vtypes else null end,'') as t24,to_char(sum(case when mday='24' then vactotal else null end),'HH24:MI') as d24,case when regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='25' then vcomment else null end,','),',,',',','g') end as c25,string_agg(case when mday='25' then vtypes else null end,'') as t25,to_char(sum(case when mday='25' then vactotal else null end),'HH24:MI') as d25,case when regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='26' then vcomment else null end,','),',,',',','g') end as c26,string_agg(case when mday='26' then vtypes else null end,'') as t26,to_char(sum(case when mday='26' then vactotal else null end),'HH24:MI') as d26,case when regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='27' then vcomment else null end,','),',,',',','g') end as c27,string_agg(case when mday='27' then vtypes else null end,'') as t27,to_char(sum(case when mday='27' then vactotal else null end),'HH24:MI') as d27,case when regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='28' then vcomment else null end,','),',,',',','g') end as c28,string_agg(case when mday='28' then vtypes else null end,'') as t28,to_char(sum(case when mday='28' then vactotal else null end),'HH24:MI') as d28,case when regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='29' then vcomment else null end,','),',,',',','g') end as c29,string_agg(case when mday='29' then vtypes else null end,'') as t29,to_char(sum(case when mday='29' then vactotal else null end),'HH24:MI') as d29,case when regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='30' then vcomment else null end,','),',,',',','g') end as c30,string_agg(case when mday='30' then vtypes else null end,'') as t30,to_char(sum(case when mday='30' then vactotal else null end),'HH24:MI') as d30,case when regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') = ',' then null else regexp_replace(string_agg(case when mday='31' then vcomment else null end,','),',,',',','g') end as c31,string_agg(case when mday='31' then vtypes else null end,'') as t31,to_char(sum(case when mday='31' then vactotal else null end),'HH24:MI') as d31, to_char(sum(vacillhours),'HH24:MI') as totalill, - to_char(sum(vacextrahours),'HH24:MI') as totalextra, - to_char(sum(vacancyhours),'HH24:MI') as totalvac from ( - select st.prename,st.surname,spd.id_staff,to_char(spd.daydate,'YYYY') as vacyear,spd.daydate,sg.id as id_staffgroup,sg.groupname, - coalesce(spd.vacancyhours::interval,'00:00:00'::interval) + coalesce(spd.vacillhours::interval,'00:00:00'::interval) + coalesce(spd.vacextrahours::interval,'00:00:00'::interval) as vactotal, - spd.vacancyhours,spd.vacillhours,spd.vacextrahours, - spd.vacancycomment, spd.vacillcomment, spd.vacextracomment, - case when spd.vacancyhours is not null then 'n' else '' end || case when spd.vacillhours is not null then 'i' else '' end || case when spd.vacextrahours is not null then 'e' else '' end as vtypes, - coalesce(spd.vacancycomment,'') || ',' || coalesce(spd.vacillcomment,'') || ',' || coalesce(spd.vacextracomment,'') as vcomment, - to_char(spd.daydate,'DD') as mday, - to_char(spd.daydate,'MM') as mmonth, - to_char(spd.daydate,'YYYY') as myear - from alicehartmann.staffreportperioddays spd - join alicehartmann.staff st on (st.id=spd.id_staff) - join alicehartmann.staffgroups sg on (st.id_staffgroup=sg.id) - where (spd.vacancyhours is not null or spd.vacillhours is not null or spd.vacextrahours is not null) and id_staff='f58b0cce-2466-1b6c-befc-033cc2d0422a' - ) vd group by staffname,groupname,id_staff,myear,mmonth order by myear,staffname,mmonth -QUERYARRAY: select st.prename,st.surname, coalesce(st.prename,'') || ' ' || coalesce(st.surname,'') as staffname, - srp.id as id_staffreportperiod, - pd.id_staff, - psplit.id_reportperiod as id_reportperiod, - min(daydate) as startdate, - max(daydate) as enddate, - to_char(min(daydate),'YYYY/MM') as ymonth, - coalesce(case when position('-' in to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text)) > 0 then '-' || replace(to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text),'-','') else to_char(sum(pd.dayhours)-sum(pd.contracthours), 'HH24:MI'::text) end,'00:00') as hoursdiff, - coalesce(to_char(sum(pd.contracthours), 'HH24:MI'::text),'00:00') as contracthours, - coalesce(to_char(sum(pd.workhours), 'HH24:MI'::text),'00:00') as workhours, - to_char(sum(pd.dayhours), 'HH24:MI'::text) as totalhours, - to_char(sum(coalesce(pd.vacancyhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancynormal, - to_char(sum(coalesce(pd.vacillhours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyill, - to_char(sum(coalesce(pd.vacextrahours,'00:00:00'::time)), 'HH24:MI'::text) as vacancyextra, - to_char(sum(coalesce(pd.otherpaidhours,'00:00:00'::time)), 'HH24:MI'::text) as otherpaidhours, - to_char(sum(coalesce(pd.partunemplhours,'00:00:00'::time)), 'HH24:MI'::text) as partunemplhours, - to_char(sum(coalesce(pd.recuperationhours,'00:00:00'::time)), 'HH24:MI'::text) as recuperationhours, - to_char(sum(coalesce(pd.nighthours,'00:00:00'::interval)), 'HH24:MI'::text) as nighthours, - sgr.groupname - from alicehartmann.staffreportperioddays pd - join ( - select id as id_reportperiod,date(date_trunc('month',date(substartdate))) as splitter,date(substartdate) as startdate, date(date(substartdate) + subinterval::interval - interval '1 day') as enddate from ( - select rpx.id,rpx.subinterval, date(generate_series(rpx.startdate::timestamp,rpx.enddate::timestamp,rpx.subinterval::interval)) as substartdate from alicehartmann.reportperiod rpx - ) gp - ) psplit on (pd.daydate between psplit.startdate and psplit.enddate) - join alicehartmann.staffreportperiod srp on (pd.id_staff=srp.id_staff and srp.id_reportperiod=psplit.id_reportperiod) - join alicehartmann.reportperiod rp on (rp.id=srp.id_reportperiod) - join alicehartmann.staff st on (pd.id_staff=st.id) - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f58b0cce-2466-1b6c-befc-033cc2d0422a' - group by srp.id,pd.id_staff,st.prename,st.surname,psplit.id_reportperiod,psplit.splitter,sgr.groupname - ORDER BY sgr.groupname,staffname, srp.id_staff,startdate desc,enddate desc; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -EXEC: UPDATE alicehartmann.staff SET color=null WHERE id='f58b0cce-2466-1b6c-befc-033cc2d0422a'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select ttr.*, st.* ,stg.groupname,'' || COALESCE(coalesce(st.surname,'') || ' ', '') || COALESCE(st.prename, '') || '
' || ''|| coalesce(st.job,'') || '' 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 (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from alicehartmann.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='alicehartmann') ttr -where st.isdeleted is null order by groupname,st.staffnumber,surname,prename; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: 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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -EXEC: UPDATE public.users set lang='de' 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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.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 - JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null and cp.portal='app'; -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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector,portal,module_vacancy,datasetname 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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 alicehartmann.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 alicehartmann.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = '86c57b67-0f53-6906-da9f-03e90e03afc6' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = '90632f2f-6134-65d8-bfd0-ab2ece5f7f7f' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = 'a0f71278-f95c-bffd-8dd7-d502f0cc88aa' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.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= '6cfa9047-f585-a84b-62b0-0e0a53c9fd08' 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/100.0.4896.88 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, - to_char(srp.nighthours, 'HH24:MI'::text) AS nighthours, - 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(nighthourstotransfer, 'HH24:MI'::text) as nighthourstotransfer, - to_char(nighthourstotransfercalc, 'HH24:MI'::text) as nighthourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM alicehartmann.staffreportperiod srp - LEFT JOIN alicehartmann.staff st ON srp.id_staff = st.id - LEFT JOIN alicehartmann.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN alicehartmann.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_reportperiod = 'a565664b-07b7-a90d-be8b-14a585d7766d' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate;